filebatch-filedirectory

how can i copy the files to corresponding folders


i have over 30k+ pdf files in a folder and most of them in fact useless, so i want to filter which i want to use so i created folders named with those i need and then i am trying to copy .pdf and .stp files in to corresponding folders, example:

i have file named XLM.371002.AA-A.pdf and XLM.371002.AA-A.stp so i creadted folder named "XLM.371002.AA" so i want to copy .pdf and .stp files in to folder XLM.371002.AA i tried few methods using .bat at first it worked but i used just 5 folders and 10 files, but when i want to do it over 600-700+ files it doesn't work, powershell opens but does nothing

@echo off
setlocal

pushd "C:\Users\Hakan\Desktop\pdfkarsan"

for /d %%I in (C:\Users\Hakan\Desktop\karsanklasor\*) do (
    for %%F in (*.pdf) do (
        for /f %%A in ('echo %%~nF ^| find /i "%%~nI"') do (
            set /p a="Moving %%F to %%I... "<NUL
            move "%%F" "%%I" >NUL
            echo Done.
        )
    )
)
popd

i found the code from here and just edited it for myself well it seems started to work after waited 30 minutes apprx. but works so slow like 6 files/h


Solution

  • From what you've submitted, I'd suggest something more like this one line batch file:

    @(For /D %%G In ("%UserProfile%\Desktop\karsanklasor\*") Do @%SystemRoot%\System32\Robocopy.exe "%UserProfile%\Desktop\pdfkarsan" "%%G" "%%~nxG-*.pdf" "%%~nxG-*.stp" /FP /Mov /NDL /NJS /NC /NS) & Pause
    

    It does not replicate your display results, but should give you enough to determine what was being copied, and where to etc.