I need some help using for
and xcopy
to move files from one folder to another based on an input text file. What I need help with is matching files based on a pattern.
My input file looks like this:
12345
abcd
My source file directory looks like this:
12345_hr.jpg
12345_hr1.jpg
abcd_hr.jpg
abcd_hr1.jpg
Lots of other files exist in this directory I want to ignore...
So I want to copy any file that matches the input file before the underscore (_
); the end result would be all the files above being moved into a destination folder.
This is what I have used in the past when I want to do exact matches:
for /f "tokens=* delims=" %%a in ('type FileList.txt') do xcopy /hrkvy ".\SourceFolder\%%a" ".\DestinationFolder"
I just don't know how to make that work with a pattern match.