1.

Solve : Using .bat to copy files to ext HD, dest. folder disappears?

Answer»

Trying to use a simple batch to copy the c:\ to an external harddrive.

Batch is :

XCOPY "c:\" "E:\Test Backup" /D /E /C /R /I /K /Y

The problem is everytime I start the batch it appears to be copying (DOS window OPENS with files scrolling) but the destination folder disappears after about 10 seconds. Theres plenty of space on the external HD. When I try to create a new folder with the same name I get the "file with this name already exists. specify new name." I've checked the "show hidden files" box and that doesnt show it either. Not sure if the batch file is the problem or if copying all of C is just too much for it. Not very experienced with .bat so that could be it. Any help would be appreciated.

DanQuote from: dbrace55 on MARCH 25, 2009, 07:44:18 AM

Trying to use a simple batch to copy the c:\ to an external harddrive.

Batch is :

XCOPY "c:\" "E:\Test Backup" /D /E /C /R /I /K /Y

Dan

What is the '/d' parameter for?

/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.When using commands, I'm fairly sure switches have to be in the order displayed in Command /?

Quote
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except EMPTY ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/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.
/Z Copies networked files in restartable mode.

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

Oh and I didn't manually write that out, I just found that you can redirect help to a file! Xcopy /? > file.txtQuote from: Helpmeh on April 07, 2009, 05:11:19 PM
When using commands, I'm fairly sure switches have to be in the order displayed in Command /?

Not always, and not with xcopy. One gramme of experiment is worth SEVERAL tonnes of guesswork, as Professor Metric might have said.

Code: [Select]xcopy /s /l /d:04-01-2009 c:\batch d:\batch
xcopy c:\batch d:\batch /s /l /d:04/01/2009
xcopy c:\batch d:\batch /l /s /d:04/01-2009
xcopy /d:04-01-2009 c:\batch /s /l d:\batch
all work just the same

source and destination have to be in that order but they can be anywhere and the switches can be in any order, and the date separator can be - or / or a mixture ie 04-01/2009 works. The /L switch is very handy when experimenting with xcopy.


Quote from: dbrace55 on March 25, 2009, 07:44:18 AM
Trying to use a simple batch to copy the c:\ to an external harddrive.


If you think that this is going to back up your system you may be in for a nasty shock if you ever need to restore it...

Quote
If you think that this is going to back up your system you may be in for a nasty shock if you ever need to restore it...

Unless your are a network administrator, there is little reason to use DOS for file backup.
The best, simple, backup method inside of Windows NT,2000,2003, XP is to just use the backup utility. The problem is that many people just do not take the time to learn how it works. Once you get it, you will never go back doing a batch to backup large file sets. It allows multiple backups, compression, PASSWORD protection, overwrite by date, save if modified, and so on. You can restore a single file, a folder, or part of a folder, several folders, and so one.
Bit of coarse, you could do it all in batch. Like using a pair of scissors instead of a lawn mower to cut the grass in the front yard.
Quote from: Geek-9pm on April 09, 2009, 01:51:00 PM
Unless your are a network administrator, there is little reason to use DOS for file backup.

I meant if he thought he was doing the equivalent of Ghosting his C: drive to back up his OS.Quote
...thought he was doing the equivalent of Ghosting his C: drive ...
Right. I missed that. Image is easier.
Here is a video he should see.
Runtime Software
DriveImage XML tutorial

Even if you do not want their free product, you want to see this video.


Discussion

No Comment Found