I need to go through a list to copy the specified files into another location.
This is the used .bat file:

for /f "delims=" %%i in ('C:\Users\Documents\test\data\list_1.4.txt') do copy "C:\Users\Documents\test\data\Golden\%%i" "C:\Users\Documents\test\data\data_1.4"

But this does not work.
Any help?

I tried this too

@echo off
set src=C:\Users\Documents\test\data\Golden
set dst=C:\Users\Documents\test\data\data_1.4
set file=C:\Users\Documents\est\data\list_1.4.txt

for /F "usebackq tokens=*" %%a in ("%file%") do xcopy "%src%\*%%~a*" "%dst%" /C /Q /H /R /K /Y 1>nul 2>nul

1 Answers

Gerhard Barnard On

Based on your comment, the file content is something like:


If that is the case, then:

@echo off
set "dest=C:\Users\Documents\test\data\data_1.4"
set "file=C:\Users\Documents\est\data\list_1.4.txt"
for /f "usebackq delims=" %%i in ("%file%") do (
    if exist "%%~fi" copy /Y "%%~fi" "%destination%"