English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to copy the directory, plus the files within it, plus any subdirectories and I want to use DOS to do this, as I'm writing a DOS batch file to go on CD-ROM.

2007-07-29 00:32:42 · 4 answers · asked by brilliant_moves 7 in Computers & Internet Programming & Design

The text above should read:
COPY D:\dir1 C:\
where dir1 is a directory containing subdirectories. DOS creates C:\dir1 and copies files, but no subdirectories. Can anyone help?

2007-07-29 00:38:06 · update #1

4 answers

If your righting a batch file and it's a CD, then you'll know all the folders thus you could use the md and copy command several times!

Just had a thought use XCOPY.EXE

C:\DOS>xcopy /?
Copies files (except hidden and system files) and directory trees.

XCOPY source [destination] [/A | /M] [/D:date] [/P] [/S] [/E] [/V] [/W]
source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies files with the archive attribute set,
doesn't change the attribute.
/M Copies files with the archive attribute set,
turns off the archive attribute.
/D:date Copies files changed on or after the specified date.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies any subdirectories, even if empty.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line

I just ran Virtual PC and installed DOS 6.22 to get the above!

2007-07-29 00:37:21 · answer #1 · answered by againyourright 4 · 1 6

==== First, major notes

1) Most importantly, use "xcopy". It has better options.

2) Also, if the /destination/ directory doesn't yet exist, then add the "/i" switch. This tells xcopy to assume that the destination is a directory if you're copying more than one file, and it will create the destination dir for you.

==== Second, some recommendations,

1) Add the "/h" switch, if you want to get hidden and system files, too.

2) Add the "/e" which copies dirs and sub-dirs including empties.

3) Add the "/c" switch. This will make the xcopy command continue to additional files/dirs even if it hits an error. This way, you'll get most stuff, then be able to figure out why it's not getting the rest.

4) If you want to get all the stuff under \source\, and you're using the "/e" switch, then the *.* is not required.

5) If you're going to do this more than once, and you want to make sure to overwrite read-only files in your destination, then add the "/r" switch.

6) If you don't want to see the "overwrite <>? (Yes,No, All)" prompt every time you run your batch, then change your "/-y" to a "/y"


===========
So, your commandline should look something like,

xcopy D:\dir1 C:\ /e /h /c /i /y /r

2007-07-29 16:18:01 · answer #2 · answered by Kevin 7 · 3 0

Use the switch /S (subdirectories) as in c:\dirt1\*.* /s. Good luck.
P.S. That should be xcopy

2007-07-29 07:36:55 · answer #3 · answered by Ghiagirl 4 · 1 2

use -r

2007-07-29 07:36:09 · answer #4 · answered by A True Gentleman 5 · 0 3

fedest.com, questions and answers