Avatar of mgcIT
mgcIT
Flag for United States of America asked on

Script to copy select folders/files based on an external list in a text file

I have a directory on a windows server that contains over 100,000 documents and I would like to copy some of these to a different drive but I need to preserve the folder structure as well.  I have a list of the folder/file names in a text file and would like a script to automate this process.  How would I do this?

For example, the directory has folders/files similar to this:

C:\Files\AAA\File1.doc
C:\Files\AAA\File2.doc
C:\Files\AAA\File3.doc
C:\Files\BBB\File1.doc
C:\Files\BBB\File2.doc
C:\Files\BBB\File3.doc
C:\Files\CCC\File1.doc
...


My text file might contain something like this:

C:\Files\AAA\File2.doc
C:\Files\BBB\File1.doc
C:\Files\CCC\File3.doc

So I would like my script to loop through the list in the text file and only copy those files while preserving the folder structure.  

So the new directory would be:

D:\Files\AAA\File2.doc
D:\Files\BBB\File1.doc
D:\Files\CCC\File3.doc



Thanks
VB Script

Avatar of undefined
Last Comment
mgcIT

8/22/2022 - Mon
Kent Dyer

Does this have to be a VBScript?

If not, I would look into the use of ROBOCOPY/FORFILES to do this task.
 
ROBOCOPY is pretty comprehensive in the sense, you can copy whole trees, apply ACLS/etc.
mgcIT

ASKER
no, does not have to be VBScript.  Can either of those only copy select files/folders based on a predetermined list?
ASKER CERTIFIED SOLUTION
Kent Dyer

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mgcIT

ASKER
Thank you
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23