I hope the title is somewhat comprehensible...
I'd like to scan a large folder (including sub-folders) for a specific list of files and copy those to a new location. So far, I have found the following lines of code:
@echo off &setlocal
set "sourceRoot=E:\source folder\"
set "sourceList=list of file names.txt"
set "destFolder=C:\destination folder\
for /f "delims=" %%i in ('dir /a:-d /b /s "%sourceRoot%\*.jpg"^|findstr /ig:"%sourceList%"') do (
copy "%%~i" "%destFolder%\"
)
PAUSE
This works just fine but naturally keeps copying all files that include one of the lines from the "sourceList". (for example, if I want to copy "saber.jpg", it will also copy "light saber.jpg" and "sabertooth.jpg") I found and tried commands like "^" and "$" or "/b" and "/e" to tell the code that the results should start AND end with the search string - but to no avail.. Sadly, I have no coding-knowledge whatsoever, and extensive googling didn't get me any further than this.
Is there any way to ensure that only files whose names are IDENTICAL to an entire line from the .txt-file are copied?
Second problem:
Within different sub-folders, there are files that bear the same name (they are different versions of the respective file). Whenever I run the code, they seem to be overwriting one another - leaving me with one version for each file name. Ideally, I would want to copy all the different versions and give the copies an extension, so that they can coexist in the destination folder. (e.g. "saber", "saber1", "saber2", etc.)
I'd like to thank everybody in advance for their help and ideas! :)
kind regards
Malte
(In case it is important in any way: I'm using Windows 7)