ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Find all files in a directory that match a list of names and make copy of each

(1/2) > >>

questorfla:
I have the list of names of missing pdf files that are all mixed up in a folder of other files.

I need a way to :
Search through the entire directory recursively looking for a match to each name in the list
if it finds one, make a copy of it and put it in a folder on c:
I can put them where they belong by copying that folder to a different system

I tried Robocopy as this>      "for /f %%f in (list.txt) do robocopy c:\source d:\dest %%f  "

But it dies so fast i barely see a flash.

I could have sworn i already had a program or script to do this but can't find it.

Thanks for help.

Thanks "4wd"
Problem solved :)

4wd:
Doesn't like '&' in the file names but it seems to work:


--- Code: Text ---@echo offset source=C:\sourceset dest=D:\destset list=C:\list.txtpushd %source%for /f "tokens=*" %%a in (%list%) do (echo.%%a && call :FindIt "%%~a")goto :End  :FindItfor /f "tokens=* usebackq" %%b in (`dir /b /s /a-d-s-h "%~1"`) do (call :DoIt "%%~dpb" "%~1")goto :EOF :DoItset str=%~1set str=%str:~0,-1%set file=%~2rem NOTE: omit /MOV to COPY insteadrobocopy "%str%" "%dest%" "%file%" /MOVgoto :EOF :Endpopd

questorfla:
this is my own addition to the mix.  I still don't have it working as needed but the windows command "Findstr" is made to search for files using a list of names.
I have not yet figured out how to get it to look only for file NAMES though instead of looking through the contents of the files.
Also, the default options of what to do with a match do not include sending a copy to another folder.
I just thought if I threw this in, someone might know of a combination of switches to get it to work with a name like:
 "Herman, George a List of Favorite Publications.pdf" and over 1000 more like it.

questorfla:
Doesn't like '&' in the file names but it seems to work:


--- Code: Text ---@echo offset source=C:\sourceset dest=D:\destset list=C:\list.txtpushd %source%for /f "tokens=*" %%a in (%list%) do (echo.%%a && call :FindIt "%%~a")goto :End  :FindItfor /f "tokens=* usebackq" %%b in (`dir /b /s /a-d-s-h "%~1"`) do (call :DoIt "%%~dpb" "%~1")goto :EOF :DoItset str=%~1set str=%str:~0,-1%set file=%~2rem NOTE: omit /MOV to COPY insteadrobocopy "%str%" "%dest%" "%file%" /MOVgoto :EOF :Endpopd-4wd (February 27, 2015, 09:10 PM)
--- End quote ---

WORKED  and true about the &  many thanks! :D :Thmbsup:
4wd wins again.

tomos:
^ I'm confused: does this mean your other thread on the topic is no longer relevant?
If so could you update the other thread? (If not, apologies for the confusion.)

Navigation

[0] Message Index

[#] Next page

Go to full version