Hi Dostips Batch Scripters, the batch process runs like below;
The bat will search through a Reference list(filename1.jpg, filename2.txt, ..etc)
from a text document(ex. ref.txt). then it will Loop copy all those files to each desire folders if the search of these files Exist in certain folders&subfolders.
If possible, it will list out the filenames which does not exist into notexist.txt
Do anyone know how to handle script like above??
Thanks.
search & copy files from reference list in a text document
Moderator: DosItHelp
Re: search & copy files from reference list in a text docume
Untested:
Regards
aGerman
Code: Select all
@echo off &setlocal
for /f "usebackq delims=" %%a in ("ex. ref.txt") do set "fullname=%%a" &set "name=%%~nxa" &call :process
pause
goto :eof
:process
if not exist "%fullname%" (
>>"notexist.txt" echo "%fullname%"
) else (
copy "%fullname%" "c:\somewhere\%name%"
)
goto :eof
Regards
aGerman
Re: search & copy files from reference list in a text docume
Hi. i tried out your batch script & it works well.. thanks
But for example, i do not know where the files are located..
probably in d: drive, in a folder, then a subfolder, another subfolders, etc..
all i got is the (file1.doc, file2.pdf, etc) from the reference list in (ref.txt)
it will not works when there is no Full Path given..
So can this batch file add in a Search features to solve this problems?
thanks!
But for example, i do not know where the files are located..
probably in d: drive, in a folder, then a subfolder, another subfolders, etc..
all i got is the (file1.doc, file2.pdf, etc) from the reference list in (ref.txt)
it will not works when there is no Full Path given..
So can this batch file add in a Search features to solve this problems?
thanks!