|I have a fair amount of experience with cmd batch scripts, but this one has me stumped. I want to copy one directory tree to another directory tree, processing each file copied with a command. |
The recursive FOR loop calls the command for each file, with the new file created as output. For example:
for %%D in (C:\source\*) do command %%D >> C:\destination\%%~nD.mod
However, this needs to be done for the entire directory tree under source. When complete, the two directory trees should be identical. The structure is many subdirectories deep, and can change. I can't simply throw in the /R switch, because I need the rest of the relative path for each output file.
There are three rules:
1) It needs to run under stock Win7, WinXP, and Win2K.
2) The source directory cannot be modified by the script, as no write permissions may be available.
3) Source cannot be copied in full and then modified. Storage may not be big enough for two unprocessed copies. I plan to xcopy (/t) the directory structure first.
I don't know how to get batch files to play nicely with relative directories (like Linux). Any help to solve this is appreciated. Thanks!