Reputation: 207
I need help writing a batch script I can run that will take a list of file names ["FileA.jpg", "FileB.jpg", "FileC.jpg"](These file names can be either in a text format or a csv) and finds those files in Folder A and then copies them into Folder B.
If there is an easy way to do this with another kind of script I am definitely open to that. I just need to figure out an automated way to get the job done.
This is the first time I have asked a question and received downvotes... an explanation for that might help as well.
Thank you in advanced for your help.
Upvotes: 0
Views: 1692
Reputation: 1
This worked for me
the files will be copied in C:\copied
@echo off REM (c) 2015 CLS TITLE file finder REM finds files in list.txt file and copies them to C:\copied REM CHECK FOR ADMIN RIGHTS COPY /b/y NUL %WINDIR%\06CF2EB6-94E6-4a60-91D8-AB945AE8CF38 >NUL 2>&1 IF ERRORLEVEL 1 GOTO:NONADMIN DEL %WINDIR%\06CF2EB6-94E6-4a60-91D8-AB945AE8CF38 >NUL 2>&1 :ADMIN REM GOT ADMIN RIGHTS COLOR 1F ECHO Hi, %USERNAME%! ECHO Please wait... FOR /R "%~dp0" %%I IN (.) DO for /f "usebackq delims=" %%a in ("%~dp0list.txt") do echo d |xcopy "%%I\%%a" "C:\copies" /e /i COLOR 2F ECHO. ECHO (c) Copying done PAUSE GOTO:EOF :NONADMIN REM NO ADMIN RIGHTS COLOR 4F ECHO. ECHO PLEASE RUN AS ADMINISTRATOR ECHO. pause GOTO:EOF
Upvotes: 0
Reputation: 6620
Try this, it requires a text file which consists of a list of all the files in a simple list format with no quotes called input.txt
:
@echo off
setlocal enabledelayedexpansion
set "FolderA=C:\..[path]"
set "FolderB=C:\...[path]"
REM Above do not end the path with "\"
for /f "tokens=*" %%a in (input.txt) do (
copy "!FolderA!\%%~a" "!FolderB!\"
Echo Copied "%%~a" to "!FolderB!"
)
And that should work fine.
Mona
Upvotes: 2