gtatechinc
asked on
Robocopy Loop Script
Hello I need to schedule a file move operation that will take PROJECTNAME input variable from a list in a text file and loop through each project name in that list. Depending on the project nam. it will move the files to the destination with an appropriate subfolder.
The list of projects would look similar to this not exceeding 4 characters
PRJ1
PRJ2
PRJ3
etc..
A Manual command would look like this
robocopy \\source\share \\destination\share\PRJ1 *PRJ1* /MOVE /Z
P.S. The * is a wild card since these files are timestamped according to project and I would like to substitute PRJ1 with the variable determined by the project name provided in the list
The list of projects would look similar to this not exceeding 4 characters
PRJ1
PRJ2
PRJ3
etc..
A Manual command would look like this
robocopy \\source\share \\destination\share\PRJ1 *PRJ1* /MOVE /Z
P.S. The * is a wild card since these files are timestamped according to project and I would like to substitute PRJ1 with the variable determined by the project name provided in the list
for /f %%a in (C:\Projects.txt) do start "%%" robocopy \\source\share \\destination\share\%%a %%a /move /z
ASKER
Hi Sir Bounty,
I created a batch file with your script above and populated projects.txt with 2 projects and modified your solution as follows:
for /f %%a in (C:\Projects.txt) do start "%%" robocopy \\source\share \\destination\share\%%a *%%a* /move /z
I popped up two shell windows simultaneously, and copied the files for the two projects simultaneoulsy. I have thousands of files so it would be ideal if it only did one project at a time because the project list will grow to hundreds of projects and be scheduled nightly as a task.
I created a batch file with your script above and populated projects.txt with 2 projects and modified your solution as follows:
for /f %%a in (C:\Projects.txt) do start "%%" robocopy \\source\share \\destination\share\%%a *%%a* /move /z
I popped up two shell windows simultaneously, and copied the files for the two projects simultaneoulsy. I have thousands of files so it would be ideal if it only did one project at a time because the project list will grow to hundreds of projects and be scheduled nightly as a task.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi again,
I have done some modifications and it is working great now Start /Wait did the trick, I will award you the points. Thanks alot. IF only I can get the logging to work properly, its seems /LOG+: only creates a log file and doesn't copy anything. Same with >> piping it to a text file.
I have done some modifications and it is working great now Start /Wait did the trick, I will award you the points. Thanks alot. IF only I can get the logging to work properly, its seems /LOG+: only creates a log file and doesn't copy anything. Same with >> piping it to a text file.
ASKER
Thanks.
/Log+ will create and append to the log file.
If you want to see logging on screen as well, add /tee
Thanx for the accept - not sure why it was scored a "B" though... : \
If you want to see logging on screen as well, add /tee
Thanx for the accept - not sure why it was scored a "B" though... : \