Does Windows Move command delete the file only on successful completion?

8

This may be a stupid question, but I'm erring on the side of caution here.

If I'm using Windows command line/batch files to Move a file from one server to another and we have a network failure, what will happen to the original file?

I would assume it remains untouched until fully moved, and then deleted, but I need to be sure. My fear is that it deletes bytes as they are moved, which would be bad.

If that isn't the case, is there a better way than Copying the file and Deleting after the copy completes?

Thanks for your help.

EDIT: I suppose super user would have been better. This is part of a job kicked off by code, so my first thought was to come here.

IronicMuffin

Posted 2009-11-25T16:38:00.007

Reputation: 225

Yes, this isn't the same as the Leopard bug. – surfasb – 2011-02-15T12:50:11.720

Answers

14

Moving on the same logical disk: Windows simply moves the file-system references atomically. Very fast.

Moving on different logical disks: Windows performs a copy from one disk to the other, then deletes the file from the first disk, once successful.

Ben S

Posted 2009-11-25T16:38:00.007

Reputation: 1 902

2

Yes, it only deletes the file once it's finished copying.

Darryl Hein

Posted 2009-11-25T16:38:00.007

Reputation: 459

2

You are correct -- Windows Move deletes only after a successful copy.

xpda

Posted 2009-11-25T16:38:00.007

Reputation: 929

1

You are correct, Windows does copy, then delete. It wouldn't make sense from a filesystem point of view to remove chunks as they are copied when all the final delete needs to do is remove the file header.

If you want to test you could always try to send a large file across the network and yank the cable partway through.

tloach

Posted 2009-11-25T16:38:00.007

Reputation: 111