?
Solved

Robocopy Loop Script

Posted on 2008-10-17
6
Medium Priority
?
1,209 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 375 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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 Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
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…
Suggested Courses

762 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