1.

Solve : Routine does everything but /s for XCOPY within FOR statement?

Answer»

Hello,

   I am trying to figure out why when I USE a standard XCOPY *.sav /s/d/y/exclude:excludedata.txt c:\saved\sav\    it will do as intended and copy the matching *.sav data files with directory tree structure copied to the destination as well, but when USING the FOR as SEEN below /s switch does not operate so all matching *.sav files are sent to C:\saved\sav without the directory tree to isolate same file names from overwriting each other, so the newest files overwite the old since the /d and /y operate. The /exclude also operates to eliminate the Cyclic Copy Error due to the source and destination being the same drive. This will skip over the C:\saved\ directory and search the rest of the drive for matching data and function.

echo \saved\ > excludedata.txt
echo excludedata.txt >> excludedata.txt

FOR /R %%G IN (*.sav) DO XCOPY /s/d/y/exclude:excludedata.txt "%%G" "C:\saved\SAV"

del excludedata.txt


Thanks!   From what I can see, by using recursion on the for COMMAND, a file name is sent to the xcopy command (%%G). Seems likely the xcopy /s switch would be meaningless in this context.

Why do you need recursion for both the for and the xcopy? Just a suggestion, but if you need the /d and /y switches, this should be done with xcopy alone.

Good luck.



Discussion

No Comment Found