jmorin1,
You can see whether the archieve bit is set by using
dir /aa
Main Topics
Browse All TopicsI am confused with regard to the switches in xcopy.
I want to copy files from a server to another location.
/s/e[creates subdirectorys and empty subdirectories]
/d [copies files only if the source files are newer than the destination files.
what does /m and /k do?
I am running the xcopy command as follows and it appears to be copying modified files at the source based on the /d switch. I want to make sure that I am doing this correctly. Could I get an explanation on what reseting the archive bit does with /m and /k? Is it resetting a date stamp based on the source file pertaining to when it was last copied or backed up? Am I way off base?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Let me better explain my dillema. I have 2 remote workstations that I want to move files from. Let's call them server1 and workstation1. I want to copy files from the workstation to the server. I also want to execute this routine without overwriting files that have remained unchanged and new files. If I am doing this from a workstation unrelated to the two do I have to map a network drive to both server1 and workstation1?
Can I write a batch job that maps the drive i.e. [net use] and copies the files and disconnects the mapping upon completion?
Hi,
I suppose you are trying to maintain a backup copy. The method you are using should work, but has the disadvantage that any files deleted from the source directory will not be deleted from the copy. Also, in general, copying only the changed elements of data should not be your only backup....there is too much danger of some kind of failure of synchronization.
The /M switch is an alternative to using the date to identify files that have to be copied. Let me explain how you can use it to do weekly full and daily incremental backups. To do this you would create two batch files, one run weekly and the the run daily.
The weekly batch file would do a complete new copy in the following steps.
- rename the existing backup folder to backup.old
- copy the entire source folder and reset all archive bits (XCOPY /S /E )
- delete the backup.old folder
The daily batch file will copy only files with the archive bit (it gets set whenever a file is created or modified)
- XCOPY /S /E /M
However, if I were you I would use ROBOCOPY instead of XCOPY. ROBOCOPY has a /MIR option to make a copy of a directory, and will automatically avoid unnecessary copying. Also, for either XCOPY or ROBOCOPY, you can use an UNC path instead of a drive mapping (e.g. XCOPY \\WORKSTATION\SHARE\FOLDER
If you are planning on running the batch script on an unrelated workstation2 to copy files from workstation1 to server1, you will need to establish drive mappings from workstation2 to workstation1 and from workstation2 to server1.
The batch file would look something like this if you intend to execute it on workstation2:
net use s: \\server1\share\ /u:userdomain\username
net use w: \\workstation1\share\ /u:userdomain\username
xcopy w:\path s:\path /s /e /m
The archive bit is supposed to distinguish file which have been backed-up/archived (archive is clear) and files which are ready to be backed-up/archived (archive bit is set). The archive bit is turned on if a file has been modified since the last time the bit was cleared. The /m switch will only copy the files which haven't changed since the last time you ran the batch script.
Is this what you wanted to do or are you trying to make a new copy of each file without overwriting the files on server1?
Ooops! Sorry, there is a big error in what I wrote earlier. XCOPY does not clear the archive bit be default. It seems that it only clears the archive bit when using the /M option, and that only copies file with the archive bit set on. This means you *cannot* combine full and differential copies in the way I suggested. In fact, it makes the /M and /A options pretty useless, IMHOP.
I would go with ROBOCOPY. I'm not sure if it's included with Win2K3 server, or if you have to install a server resource kit.
You can download it from http://www.microsoft.com/d
http://www.xxcopy.com/ is a very good solution (for me at least).
And in XCOPY?
net use Y: \\Workstation1\C$
net use Z: \\Server1\C$
XCOPY /D /E /C /I /H /Y Y: Z:
net use Y: /del
net use Z: /del
I think you can do this with UNC naming as well. But I think that would require quotes around the name.
Hi;
I think if you want to 'mirror' your drives your answer is ROBOCOPY. You can download Robocopy from the location provided by Carlo.
Simply create 2 shares (source, destination) and a batch file. Schedule your batchfile and ensure ROBOCOPY is reachable (either in same directory or in your path directories such as C:\winnt\system32)
The command you might want to use is:
robocopy \\workstation\share \\server\share /E /Z /MIR /R:10 /W:90 /ETA /LOG+:AppendLog.log
This will MIRROR your files from the Workstation to the Share. Files deleted on the WS are also being deleted on the Server, it will copy empty and full subdirs, in restartable mode and if the connection drops it will wait 90 seconds before retry. It does that max. 10 times. ETA is the Estimated time of Arrival, can be replaces by /NP (No Progress). /LOG+: is creating a log and appending to exsting log. You could make it more dynamic of course by using a log per day using a variable.
If you do robocopy /??? you will get a very detailed help. You can for example set Attiributes and check for them, so rather then using mirror you will check for that. Also you can use /SEC to copy the security information (both source / dest must be NTFS).
Let me know your results.
BTW. The newest version of robocopy is found in the Windows 2003 RK-Tools Kit.
It's available on: http://www.microsoft.com/d
This version is (for as far as I've tested) running under Windows 2000, but has some new options which might be useful.
One thing: I could't extract the rktools pack completely under W2K, so I used a WXP machine for that. After that, no problem on using the Tools.
Business Accounts
Answer for Membership
by: mgh_mgharishPosted on 2005-04-14 at 11:29:22ID: 13784469
Hi jmorin1,
ile3]...]
le3]...
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][+f
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][+fi
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.
Bye
---
Harish