Hi JDobb, is there any reason that you cant do a two step process? Like create your list, then go back and have XCOPY work on the original directory. XCOPY is works fine for me with spaces in the file names, and it is designed to work on multiple files, where it looks like you are using it on individual files in the for loop.
xcopy "*.txt" J:\test\test2\*.*
here is a backup file that I use now and then
Code:
@echo off
@echo Process saver run history
@type 00SaveProcesses.log
echo.
echo this will backup the "Processes" folder to the primary backup (\\LEN\L)
pause
xcopy c:\users\PB\datapart\Processes\*.* \\len\Processes\*.* /s /d /y /f /c
::/y suppress overwrite prompting
::/f display full file names as copying
::/c continues on error
::/s subdirectories
::/d only newer files
echo complete %date% --- %time% >> 00SaveProcesses.log
I have several other varations of this basic idea if you work best from examples.
Caution, while you are working this out, Use the /L flag on XCOPY to check that it is going to work before running, or in your for loop
Code:
do @echo xcopy %%j ...
to show what it is going to do before you do it. Remember that the commandline has no pity, and it will eat your lunch without asking.
If you want to use the FOR loop, check in help where it describes the /F "options" part. You have to be careful with the "delims=..." section to get it right.
and be especially careful using batch code that you find on the internet