Windows – Move files across computers with command line (Windows)

command linenetwork-shareswindows

I have a VM running XP on which files get uploaded at random moments.
I need a script or utility fit for the command line, that would run every X minutes (for instance) and MOVE all uploaded files to a shared dir on a Win7 box.

Now, the command-line move command doesn't run across drives, even less so across shares.
(And it gives the super helpful message Access denied.)

I could do a

copy src desr_share
rm src

…but here's the tricky part:

When the copy command runs, it may happen that a file is uploaded at the same time. The copy may upload just a chunk of the file, or skip it completely and move on, but later, when the rm kicks in, the file may be completely uploaded, and the rm will erase it, without it having been properly copied to the destination.

So I need something that has the move semantics (copy a file and delete it only if successful), but that would work across machines.

Any suggestions?

PS. I don't mind if a file gets only partially moved, as long as it's not then deleted. I will force overwriting any destination files, and on the next run, the file will be uploaded again, completely.

Best Answer

Look into Robocopy, which is standard on Win7 and is available in a microsoft dev kit for xp.

use robocopy /? (or robocopy /? > drive:\path\robocopy_options.txt) for options.

Windows 7:

http://technet.microsoft.com/en-us/library/cc733145%28v=ws.10%29.aspx

Windows XP:

http://www.microsoft.com/en-us/download/details.aspx?id=17657#Requirements

Related Question