Solved

Robocopy Loop Script

Posted on 2008-10-17
6
1,127 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:gtatechinc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22748279
for /f %%a in (C:\Projects.txt) do start "%%" robocopy \\source\share \\destination\share\%%a %%a /move /z
0
 

Author Comment

by:gtatechinc
ID: 22748500
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.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 22750353
then just remove start and the "%%a"

for /f %%a in (C:\Projects.txt) do robocopy \\source\share \\destination\share\%%a *%%a* /move /z
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:gtatechinc
ID: 22750369
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.
0
 

Author Closing Comment

by:gtatechinc
ID: 31507383
Thanks.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22756780
/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... : \
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question