xcopy, wont work like I want, and going I'm going fricking..

G

Guest

Guest
Archived from groups: alt.msdos.batch,microsoft.public.win2000.general (More info?)

a windows 2000 server of mine hosts a DOS database that I want to involve in
an automated backup script, thing is if I try to do ntbackup directly to
that db it sometimes wont work because of perceived open files, so my idea
was to copy everything I need to another directory and then backup up that
directory

the folder I want to copy has lots of directories inside of it as well as
other types of files, oh, and some directories have lots of subdirectories

when I try to xcopy I can either (depending on the switches) get the
directories to copy or the root files but never both

how can I, from the command line, copy a folder and all of its contents to
another folder, period?
 
G

Guest

Guest
Archived from groups: alt.msdos.batch,microsoft.public.win2000.general (More info?)

Mostro wrote:
> when I try to xcopy I can either (depending on the switches) get the
> directories to copy or the root files but never both
> how can I, from the command line, copy a folder and all of its contents to
> another folder, period?
>

I almost always do

xcopy /s/h/e fromfolder tofolder

/S Copies directories and subdirectories except empty ones.
/H Copies hidden and system files also.
/E Copies directories and subdirectories, including empty ones.

Sometimes when I'm copying files across a WAN, I use

xcopy /s/h/e/c/r/y

/C Continues copying even if errors occur.
/R Overwrites read-only files.
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.

just so it won't stop copying because of network glitches, or read-only files.
These WAN copies take longer, and I want to give them the best chance to complete
in an unattended mode.
 
G

Guest

Guest
Archived from groups: alt.msdos.batch,microsoft.public.win2000.general (More info?)

thanks for your help!


"Mostro" <oveloz@glasfloss.com> wrote in message
news:d147ah$p7e$1@newsdbm04.news.prodigy.com...
>a windows 2000 server of mine hosts a DOS database that I want to involve
>in an automated backup script, thing is if I try to do ntbackup directly to
>that db it sometimes wont work because of perceived open files, so my idea
>was to copy everything I need to another directory and then backup up that
>directory
>
> the folder I want to copy has lots of directories inside of it as well as
> other types of files, oh, and some directories have lots of subdirectories
>
> when I try to xcopy I can either (depending on the switches) get the
> directories to copy or the root files but never both
>
> how can I, from the command line, copy a folder and all of its contents to
> another folder, period?
>
 
G

Guest

Guest
Archived from groups: alt.msdos.batch,microsoft.public.win2000.general (More info?)

"Mostro" wrote in message
....snip
> the folder I want to copy has lots of directories inside of it as well as
> other types of files, oh, and some directories have lots of subdirectories
>
> when I try to xcopy I can either (depending on the switches) get the
> directories to copy or the root files but never both
>
> how can I, from the command line, copy a folder and all of its contents to
> another folder, period?

XCOPY will copy the contents of subfolders with the /s switch. Note
that if any files are "in use" during the XCOPY it will stall unless
you use the /c (continue on error) switch.

XCOPY recreates the Source folder structure on the Target, for example:

:: Example XCOPY line
xcopy C:\WORK\*.* E:\TARGET\BACKUP\*.* /s /c /e

This line copies all C:\WORK files and subfolders (including nested
subfolders) and their contents to E:\TARGET\BACKUP so that say, a
subfolder DATA such as C:\WORK\DATA becomes E:\TARGET\BACKUP\DATA

The /e switch is optional - it merely includes Empty subfolders.

Note that the /d (date dependent) switch is worthwhile considering:
:: Example XCOPY line with date dependency
xcopy C:\WORK\*.* E:\TARGET\BACKUP\*.* /s /c /e /d

This line works as before, except that only new or changed files are
copied, so if a file doesn't need copying (because current date/time
version exists on target), it will be skipped.

Note that:
:: Example XCOPY line with date dependency
xcopy C:\WORK\*.* E:\TARGET\BACKUP\*.* /s /c /e /d >NUL

will suppress the list of files copied and:
:: Example XCOPY line with date dependency
xcopy C:\WORK\*.* E:\TARGET\BACKUP\*.* /s /c /e /d >C:\LOGS\LOGFILE.TXT

will log the files copied to C:\LOGS\LOGFILE.TXT

Notes:
(a) The trailing \*.* wildcards prevent XCOPY asking whether the
specifications in its command line are files or folders.

(b) If you want to XCOPY to or from a remote machine, you'll need
to use the UNC path in the command line folder specification.
To find a UNC path to a file or folder:

(1) Open an MS-DOS window
(2) In the MS-DOS Window, type: REM+[Space] (but don't press Return)
(3) Open Windows Explorer
(4) Locate the file or folder in Network Neighborhood
(5) Left-click-hold file/folder, drag-and-drop it the MS-DOS Window

The MS-DOS window will have a REMark showing the full short form path.
The use of REM avoids accidental execution of any program file located
by this method.

If Explorer obscures the MS-DOS window at stage (5), hover
briefly over the Taskbar button for the MS-DOS window during the
drag-and-drop (don't release the mouse button) - the MS-DOS window
pops back into focus and you can easily drop the file/folder on it.

The same drag-and-drop technique can be used to find the full short
form path to a file or folder on the current machine.

--
William Allen
Free interactive Batch Course http://www.allenware.com/icsw/icswidx.htm
For example Batch Files see: http://www.allenware.com/find?BatchLibrary
Creative Technical Writing - Allen & Company: http://www.allenware.com/