|I have a text list of about 3000 numbers/names that correspond (only partially) to file names in a folder/subfolders that need to be compiled into one new folder (files only; not directory structure).|
I would like to search the main folder and subfolders for all hits to these numbers/names, and create a list of file names/paths.
Then, using the list of paths, I would like to move the listed files to a new folder.
I have had success with the first portion of the task (searching and listing file names). The code I am using is below (searchtext.txt contains the numbers to search).
for /f %%a in ('type "C:\searchtext.txt"') do dir /b /s |Find "%%a" >> C:\files2move.txt
I am having trouble with the second task(copying the listed files to a new folder). What I have tried is below:
for /f %%a in ('type "C:\files2move.txt"') do xcopy "%aa" C:\newfolder
When I run this code I get a parse error. I have also tried the move command. The file/folder names/paths in the list are long and contain spaces. I know this might be a problem, but I am not sure how to fix this.