|Thanks Razor! I stand corrected on forfiles, since I do continue with XP. Comments in color, no less!|
@OP, As for query #1, if the dir. structure is topoligically consistant, you need change only the value of the constant "data\operations\setup", but if they're further down or up the directory tree, then yes, you need to modify the tokens in line 5 to reflect that.
And for #2, as Razor implied, you should be able to just change *.doc to *.doc?
Also, since it was late, and I was tired, I didn't do much "detail work", such as changing to or otherwise accounting for "G:\". I will try to address all these items:
@echo off & setlocal
::----- dynamic section: change foll lines as needed
:: foll. 3 lines must be kept consistant and in synch
::==== end dynamic, begin static section main code
:: the foll line just isolates "setup" from the end of the marker-path-string
for %%a in (%marker%) do set end=%%~nxa
for /f "tokens=*" %%a in ('dir /b /ad /s "%end%"') do (
for /f "tokens=*" %%b in ('dir /b /s "%%a"\*.doc? 2^>nul') do (
for /f "tokens=%range% delims=\" %%c in ("%%b") do (
if /i %xx% equ "%marker%" echo copy "%%b" "%copydest%"
::====== end script
Note that nothing takes place other than the creation of a "slave" batch file, in current working directory of the primary drive, which is not executed. This allows you to pre-scan it for errors. It will be created in your original working directory.
For your edification concerning the content above, from cmd prompt type: FOR /?
edited to fix a couple of errors, for the record.
message edited by nbrane