0
votes

I have a batch file that is copying data from a source folder to a destination folder. A text file called list.txt decides which folders from the source folder will be copied to the dest folder. The contents of the text file, list.txt, are:

F:\200208
F:\200210
F:\200214

The batch file is:

@echo off
for /f "tokens=*" %%i in (list.txt) do (
        xcopy /s /i "%%i" "D:\username\Videos\%%i"
    )
pause

However, when I run the batch file, I get the following error messages:

Invalid path
0 File(s) copied
Invalid path
0 File(s) copied
Invalid path
0 File(s) copied
Press any key to continue . . .

The name of the drive in which this batch file is residing is F and folders with name 200208, 200210 & 200214 do exist in that same drive F. Also, the dest folder exists.

Can someone point out where the issue is?

1
Put an ECHO at the beginning of the line inside your loop so you can can see the problem. It would look like ECHO xcopy /s /i "%%i" "D:\username\Videos\%%i". - aphoria

1 Answers

1
votes

The destination path in your code is resolving to "D:\username\Videos\F:\200208". That is why you are getting an invalid path.

You just want the folder name so change %%i to %%~nxi in the destination path.