?
Solved

Robocopy syntax to copy folder and files

Posted on 2014-12-30
5
Medium Priority
?
252 Views
Last Modified: 2014-12-31
I need to copy or move a complete folder from one location to another. For example I need to copy or move the folder 2010 (F:\projects\2010) to \\fileserver\archives.

The syntax and examples I see for robocopy are all about copying the files in a folder to another folder, but I need to move the complete folder.  I have a feeling this is really simple and I will feel dumb, but I just can't quite get it.
0
Comment
Question by:gglollc
[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
  • 2
  • 2
5 Comments
 
LVL 25

Expert Comment

by:NVIT
ID: 40524807
To copy...
robocopy F:\projects\2010 \\fileserver\archives\2010

Open in new window


To move...
robocopy F:\projects\2010 \\fileserver\archives\2010 /move

Open in new window


If you're not familiar with how it works, be sure to test using the /nocopy switch
Also, the /LOG and /LOG+ switches are helpful for post examination.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40525214
By default, RoboCopy will only copy files. But all you need to do is to add /s (without empty subfolders) or /e (with empty subfolders).
robocopy F:\projects\2010 \\fileserver\archives /s
REM or
robocopy F:\projects\2010 \\fileserver\archives /s /move

Open in new window

But that will copy/move the contents of the 2010 folder into archives, the folder itself will not be created.
0
 

Author Comment

by:gglollc
ID: 40525817
Okay, thanks. So I will create the 2010 folder at the target first.
0
 
LVL 25

Accepted Solution

by:
NVIT earned 2000 total points
ID: 40525845
...I will create the 2010 folder at the target first
...or revise Qlemo's code, including the folder name:

robocopy F:\projects\2010 \\fileserver\archives\2010 /s
REM or
robocopy F:\projects\2010 \\fileserver\archives\2010 /s /move

Open in new window


If you have a bunch of folders to process, e.g. 2010, 2011, 2012...
make a .bat file with something like this. Note: Remove the ECHO to run it for real:

for /d %%a in (201?) do (
  ECHO robocopy F:\projects\%%a \\fileserver\archives\%%a /s /move
)

Open in new window

0
 

Author Comment

by:gglollc
ID: 40525987
Got it, thanks! Works great.
0

Featured Post

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

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…
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

770 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