Using XCOPY to copy only changed files

H

hmm

I am trying to use the /D switch after the XCOPY command to exclude
overwriting files in the destination directory when the source file was not
modified since the last XCOPY. But it still overwrites. Can anyone clue me
in on what I am doing wrong? (According to the help instructions, the /D
switch, when no date is given, "copies only those files whose source time is
newer than the destination time.") Thanks.

<This question was also posted in TechNet How-to needs.>
 
B

Big_Al

hmm said:
I am trying to use the /D switch after the XCOPY command to exclude
overwriting files in the destination directory when the source file was not
modified since the last XCOPY. But it still overwrites. Can anyone clue me
in on what I am doing wrong? (According to the help instructions, the /D
switch, when no date is given, "copies only those files whose source time is
newer than the destination time.") Thanks.

<This question was also posted in TechNet How-to needs.>
I'd use robocopy. Its part of a free download from MS. Look for
'Windows Resource Toolkit'. It will be a zip file and in it is
robocopy. Install the toolkit and it builds a start menu entry. On
the command line you can type robocopy by itself and get help.
Robocopy is a robuts copy program that allows for a /MIR argument to
specify you want to mirror folderA to folderB. It copies what has
changed, and deletes what was deleted and skips all the unchanged files.
 
T

Terry R.

The date and time was 11/19/2008 1:25 AM, and on a whim, hmm pounded out
I am trying to use the /D switch after the XCOPY command to exclude
overwriting files in the destination directory when the source file was not
modified since the last XCOPY. But it still overwrites. Can anyone clue me
in on what I am doing wrong? (According to the help instructions, the /D
switch, when no date is given, "copies only those files whose source time is
newer than the destination time.") Thanks.

<This question was also posted in TechNet How-to needs.>

Hi hmm,

I have seen this when copying to network drives for client workstations,
but not local.

I use xcopy with the /d switch to copy modified files to another drive
each shutdown, and the log files I have created on the Desktop only show
modified being copied.

--
Terry R.

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.
 
D

Dave Cohen

hmm said:
I am trying to use the /D switch after the XCOPY command to exclude
overwriting files in the destination directory when the source file was not
modified since the last XCOPY. But it still overwrites. Can anyone clue me
in on what I am doing wrong? (According to the help instructions, the /D
switch, when no date is given, "copies only those files whose source time is
newer than the destination time.") Thanks.

<This question was also posted in TechNet How-to needs.>
I don't use the /d switch. I've seen posts by people who don't like to
rely on the modified attribute bit, but I've never had a problem with
the /m switch.
For more serious syncing, I recently discovered winmerge, a free
download with a graphical interface. But for backup almost every time I
shutdown, a little xcopy batch file to a flash drive using a desktop
icon is hard to beat. If you always use the same flash drive,
permanently assign a drive letter using disk management.
Dave Cohen
 
J

Jack Gillis

Terry R. said:
The date and time was 11/19/2008 1:25 AM, and on a whim, hmm pounded out


Hi hmm,

I have seen this when copying to network drives for client workstations,
but not local.

I use xcopy with the /d switch to copy modified files to another drive
each shutdown, and the log files I have created on the Desktop only show
modified being copied.

--
Terry R.

***Reply Note***
Anti-spam measures are included in my email address.
Delete NOSPAM from the email address after clicking Reply.

Pretty much the same here and has been that way for years, Terry. Never
tried it with network drives though.
 
A

Anthony Buckland

hmm said:
I am trying to use the /D switch after the XCOPY command to exclude
overwriting files in the destination directory when the source file was
not
modified since the last XCOPY. But it still overwrites. Can anyone clue
me
in on what I am doing wrong? (According to the help instructions, the /D
switch, when no date is given, "copies only those files whose source time
is
newer than the destination time.") Thanks.

<This question was also posted in TechNet How-to needs.>

Here's the XCOPY line from the supplementary job
I run to quickly back up My Documents to a thumb
drive most days (assumes you are in the folder at
the head of the structure you want to selectively save,
and that the destination is set to the corresponding folder
on J:)

XCOPY *.* J: /D /E /C /Q /H /R /Y /K

This works fine regarding not spuriously overwriting.
And quickly.
 
H

hmm

Thanks Bob.

I already use the /M switch to exclude files I don't want to copy at all.
The /D switch is intended to exclude files that I want copies of, but that
have not changed since the last XCOPY.
 
P

Pegasus \(MVP\)

The /d switch can cause problems when copying between different file
systems. AFAIR, the FAT32 file system uses a granularity in the date stamp
of 2 seconds whereas NTFS uses 1 second. You can get around this issue with
xxcopy.exe, downloadable from a number of sites.
 
H

hmm

Interesting. The disk I am writing to uses the INCDFS file system, a Nero
system that allows a DVD to be accessed directly by Windows (W. Explorer &
Command Line). Could this be the source of the problem? (See, also, my new
post on this topic.)
 
H

hmm

Thanks to all for your comments.

I have not yet solved the problem, but here are two additional pieces of
information:

1. I tested XCOPY /D again. It is working fine when I XCOPY a folder
containing MP3 files, but it requests permission to over-write I XCOPY
folders containing other file types (EXE, TXT, DOC, XLS, PDF, etc.).

2. In all cases, the file system of the destination drive is INCDFS, a Nero
system that allows Windows to write to DVD (from Windows Explorer or Command
Line).

Perhaps the above facts are relevant. Can anyone help me to get XCOPY /D
working? Thanks.
 
P

Pegasus \(MVP\)

hmm said:
Interesting. The disk I am writing to uses the INCDFS file system, a Nero
system that allows a DVD to be accessed directly by Windows (W. Explorer &
Command Line). Could this be the source of the problem? (See, also, my
new
post on this topic.)

Sorry, can't see any new post from you. You can test my suggestion by
running the script below on a number of files both on the source and the
target file system. Files on NTFS partitions will show a resolution down to
1 second, those on FAT partitions down to 2 seconds.

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oArgs = WScript.Arguments
If oArgs.Count = 0 Then
WScript.Echo "Please supply a file name as a parameter"
WScript.Quit
End If

If Not oFSO.FileExists(oArgs(0)) Then
WScript.Echo "File """ & oArgs(0) & """ not found"
WScript.Quit
End If

WScript.Echo "The date stamp for """ & oArgs(0) & """ is " _
& oFSO.GetFile(oArgs(0)).DateLastModified

Instructions
========
1. Copy & paste the code above into c:\Test.vbs
2. Run this command from the Command Prompt:
cscript //nologo "X:\Some Folder\Some File.ext"{Enter}
 
H

hmm

Here is an example of an XCOPY command that is asking me whether I want to
overwrite each existing destination file, even though it has the same
modification date as the source file (rather than skipping such files as
indicated by the /A switch).

XCOPY "C:\Documents and Settings\hmm\My Documents\Miscellaneous Docs\*.*"
"D:\My Documents\Miscellaneous Docs\" /A /D /E /V

As I said before, I am copying from my hard drive (NTFS filing system) to a
DVD (INCDFS filing system).

Any help would be appreciated. Thanks.
 
B

Bob I

Remove the /A
Here is an example of an XCOPY command that is asking me whether I want to
overwrite each existing destination file, even though it has the same
modification date as the source file (rather than skipping such files as
indicated by the /A switch).

XCOPY "C:\Documents and Settings\hmm\My Documents\Miscellaneous Docs\*.*"
"D:\My Documents\Miscellaneous Docs\" /A /D /E /V

As I said before, I am copying from my hard drive (NTFS filing system) to a
DVD (INCDFS filing system).

Any help would be appreciated. Thanks.


:
 
H

hmm

Thanks Bob. I tried it, and unfortunately, it still asks me if I want to
overwrite files where the modified date/time is exactly the same for both the
source and destination files.

Anyhow, it is useful, because I clear the archive flag for files I don't
want copied at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top