简体   繁体   中英

Windows cmd shell xcopy to network directory doesn't work

Im trying to make a batch file that will copy all new files and folders from a source folder to an network directory. All the new subdirectories and new files should be copied (backup).

My code:

xcopy "C:\\Source" "T:\\Backup" /d/i/s/q

( /d for only new files, /i because source is a dir, /s for all the subdirs and files, /q just to supress the copy text)

Source contains both subdirectories and files (.txt).

The first run it copies Everything as it should. When I add a new .txt file to one of the existing subdirectories and run it again I get the message:

"An error occured when the file The directory is not empty. was being created. The folder "T:\\Backup" could not be created. 0 files copied. (Translated from Swedish so not 100% original)

The thing is when I try this command to a local source like eg "C:\\test" and do the same procedure it works.

Anyone who can understand why this doesn't work for the network drive? Should I try Another command such as robocopy?

Skip xcopy and use robocopy with the /E flag instead. It's built into all recent versions of Windows. Free download for XP.

Example:

robocopy c:\source T:\backup /E

That will copy all the files in the "source" folder to the "backup" folder that haven't been copied already.

And if you don't want to have the output shown on the console (equivalent to the /Q option in xcopy):

robocopy c:\source T:\backup /E /LOG:nul

Robocopy must be better because it should create directories with the \\E switch. No overwrites for files, just adds a file with extra letters or extension <> command. Still must defrag.

XCOPY“DRIVE LETTER:\\ windows.old \\ USERS”“\\ computername \\ D \\ NAME \\”/ D / E / C / R / I / K / Y / f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM