Script/batch file to copy and rename select folders
Posted on 2007-03-26
I need a script/batch file for copying folders automatically from Windows Server (Small Business Edition) to a connected hard drive.
1) We have a directory on our server called PROJECTS. It contains subdirectories for each project we work on. Each subdirectory’s name begins with the project number (almost always four digits: 1001, 1002, 1003, etc.). It contains a short description after the project number, but always begins with the four (eventually five, I guess)-digit project number.
2) We want to write a script that COPIES project subdirectories from the PROJECT folder to a separate hard disk. The code would do the following:
- scan through the PROJECT folder’s subdirectories, looking for any project whose FIRST CHARACTER is ALPHA (not numeric).
- for that directory, it would check the other hard disk to see whether a similarly named folder already exists.
- if it does NOT exist, it would COPY the entire folder and then RENAME the source folder (either insert another character at the beginning or end of the folder name – we’re flexible on this naming convention).
- if it DOES exist, it would simply skip the folder. [nice to have: store this information in a text file generated at the end, ideally listing the folder size on the original and on the remote hard drive – strictly “nice to have”]
Thanks for your assistance on this!!