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
Solved

create a script read a txt file and move folders.

Posted on 2013-01-18
4
402 Views
Last Modified: 2013-01-18
I have a c:\users.txt file which contains a list of user IDs.  

I need to create a script to read the users.txt file and "MOVE" the subfolders in the M:\USERS directory into another server (\\SERVER1\DUMP\USERS).

Will this script works?

for /f %%a in (c:\users.txt) do move m:\users\%%a \\server1\dump\users

I tried to just run "move m:\users\%%a \\server1\dump\users" in the command prompt but it returns "Access is denied".  

It is a Administrator session so I do not know what it the problem.  I have verified right from windows explorer.
0
Comment
Question by:nav2567
  • 2
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 38793810
The basic move command won't support this.  I would suggest ROBOCOPY instead, like this:

for /f %%a in (c:\users.txt) do robocopy m:\users\%%a \\server1\dump\users\%%a /move /e

Open in new window

~bp
0
 

Author Comment

by:nav2567
ID: 38794804
Works.

Thanks, Bill!
0
 

Author Closing Comment

by:nav2567
ID: 38794807
Thanks.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 38795617
Welcome, glad that was helpful, thanks for the feedback.

~bp
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

838 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