samiam41
asked on
Child directories defined in script
Hey Experts. I am using a script (which was authored by one of the superstars on EE) which copies files based on their file extension within two directories. That function works flawlessly. What I am looking at now is having the script look at those two directories and all sub-directories for the files to copy.
Such as:
Test (dir)
>Test\A
>Test\B
>>Test\B\1
I'm not sure how to define that in the script (see below). Thank you in advance for your help.
Such as:
Test (dir)
>Test\A
>Test\B
>>Test\B\1
I'm not sure how to define that in the script (see below). Thank you in advance for your help.
@echo off
set DirList="D:\Test","D:\Test1"
set DestDir=d:\Home
set ExtList="doc","docx","pdf","vsd"
for %%A in (%DirList%) do (
for %%B in (%ExtList%) do (
copy "%%~A\*.%%~B" "%DestDir%"
)
)
If you just want a copy in the dest folder, then I think this should do that.
@echo off
set DirList="D:\Test","D:\Test1"
set DestDir=d:\Home
set ExtList="*.doc","*.docx","*.pdf","*.vsd"
for %%A in (%DirList%) do (
for /R "%%~A" %%B in (%ExtList%) do (
copy "%%~B" "%DestDir%"
)
)
~bp
ASKER
@bp, you are exactly right. What appears to be happening is that the script isn't pulling the files from the second directory listed.
ASKER
Copying files from "test" but not "test1". High probability that is in relation to the user (me) running the script.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Insane. Sick. Perfect.
Thanks billprew. Simply amazing!
Thanks billprew. Simply amazing!
Thanks, you're too kind.
~bp
~bp
~bp