316Views6Replies

Author Options:

Copy a specific directory in batch? Answered

I am working on a batch file to back up specific folders, the directory is layed out lime this:

Main Folder>saves>world1>etc
                                     world2>etc
                                     world3>etc

Basically, I need a command to copy "world1" or whatever folder it is, but the entire thing, not just the contents. If I copy it to the desktop, it just copies the contents, I want it to directly copy the directory and subdirectories, so that it would show in the target area as "world1". How do I do this with xcopy?

Tags:batch

6 Replies

user
AndyGadget (author)2011-02-04

If you're writing a backup batch, have a look at Microsoft's ROBOCOPY command line utility. I use it for backing up various directories from several PCs. 

Select as Best AnswerUndo Best Answer

user
XOIIO (author)AndyGadget2011-02-04

Windows 7 has robocopy, but A lot of people have XP, and this batch file is made to be easy to use, so it should be universal, like xcopy

Select as Best AnswerUndo Best Answer

user
AndyGadget (author)XOIIO2011-02-05

Fairy nuff, if you're making a portable batch.
(I didn't realise they'd included robocopy in Win7.  I got it from a Resource Kit 'long time ago.)

Select as Best AnswerUndo Best Answer

user
XOIIO (author)AndyGadget2011-02-05

Yeah, I found ot while browsing the help menu. it is a great program.

Select as Best AnswerUndo Best Answer

user
NachoMahma (author)2011-02-04

.  /S will copy non-empty sub-directories. /E will copy all sub-directories. Google is your friend.

Select as Best AnswerUndo Best Answer

user
NachoMahma (author)NachoMahma2011-02-04

. That should be /S /E together will copy all sub-dirs. /E by itself won't do it.

Select as Best AnswerUndo Best Answer