Would like to seek your help on creating simple bat file that will copy specific file from source to destination. Eg.
Source = C:\Source
Dest = D:\Destination
File in source:
123.CSV
234.CSV
456.CSV
567.CSV
678.CSV
789.CSV
012.CSV
and I only want to copy the ff:
123.CSV
456.CSV
678.CSV
012.CSV
and delete others after copying.
Script:
@ECHO OFF
CHCP 65001 > NUL
FOR /F "usebackq delims=" %%I IN ("G:\SOURCE\123.CSV") DO (
xcopy /s "G:\SOURCE\123%%I" "G:\DESTINATION\%%I*"
)
PAUSE
Thank you for your help in advance
FOR /Fcommand you are using reads the contents of a file and for each line it reads it assigns the output of the line to theFORmeta-variable%%I. Why are you doing that? You made no mention of using a file as the source for what files you want to copy. You also made no mention of copying these files from subdirectories and theXCOPYcode is doing so.XCOPYcommands?xcopy "G:\SOURCE\123.csv" "G:\DESTINATION\". Rinse and repeat.