Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to copy multiple folders based on criteria?

Status
Not open for further replies.

JGKWORK

IS-IT--Management
Apr 1, 2003
342
GB
Hi all,

Really could do with some help please. Any way to do a batch file (bearing in mind this is over two network drives) to do the following? Or if anyone knows if fileboss program does this?

We are facing a huge task at work to COPY thousands of folders in to a new folder structure.

The folders which need transfered are named:

\schemes\"001 Scheme name"
\schemes\"002 Scheme name"
\schemes\"003 Scheme name"

etc etc

Each of these folders need to be transfered in to their respective "Asbestos" folders shown in the path below:

\Properties\001 Random name\Asbestos
\Properties\002 Random name\Asbestos
\Properties\003 Random name\Asbestos

So as you can see (hopefully) I need to be able to transfer the, for example "001 Scheme name" folder in to an "Asbestos" folder that sits within a folder that contains the same scheme number e.g. 001, 002 etc.

So the final folder path for each scheme would look like this:

\Properties\001 Random name\Asbestos\001 Scheme name
\Properties\002 Random name\Asbestos\002 Scheme name
\Properties\003 Random name\Asbestos\003 Scheme name

So there needs to be some code which contains a wildcard to check for the scheme number e.g. move scheme folder in to "Asbestos" folder which is within folder like 001*

Please help, this could save us days of agony!

Many thanks.

 
I can't help with the batch file setup, but just wondering... from a programming perspective, is "Random name" really going to be just some random name? If so, it'd be kind of difficult to program the whole process. For simplicity sake, I'd imagine it best to keep the whole folder address as uniform as possible.
 
It will be random, the only thing that is consistent is the scheme name.

I'm thinking what I need is a copy command combined to a piece of code that creates the file paths based on comparing the folders with a wildcard e.g. if contains *001*.
 
I think this would be easier to do in VBScript than standard batch language. Might be best to repost here: forum329



Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
I feel the structure would be as follows (all of which would be done in a loop):

1.Return the folder name from the source directory and add it to a variable.

2.Extract the number from the folder name (only ever going to be one set of numbers in the file name).

3.Use this number to match against the folders in the destination folders and where it matches add that folder/file destination to a variable.

4. Run the copy command using the two variables from above.

Can someone let me know of I'm dreaming with any of these as you can tell I'm cr*p when it comes to DOS/batch scripts etc!

Who's up for the challenge?!

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top