windows 7 - Moving files unattened with cmd prompt
2014-04
I'm trying to move over 500GB+ and it will take about a day. Is there a way under Windows 7 to move all these files using a command line that will answer yes to any pop-up dialogs?
For example, should it timeout or something I want the transfer to keep on going.
Yes and no!!
If it is a timeout then it won't continue, it's time out! And even if you could continue, what is the point in continuing as you'll have no indication if the copy was successful or not (in terms of what files did / didn't copy)).
However, to override the prompts and do most things:
I used to use the following
xcopy "source" "destination" /i /e /y /z
/z
Copies over a network in restartable mode.
/i
If the destination does not exist, and you are copying more than one file, this switch assumes that the destination is a folder.
/y
Overwrites existing files without prompting you.
/e
Copies any subfolder, even if it is empty.
Now a-days, Robocopy is the better and faster choice and syntax is near identical.
robocopy "C:\sourceDirectory" "C:\backups\destinationDirectory" /e /z
If you save this as a .bat file, you can add the line PAUSE. This is very useful as it will display the last results etc, which if it's an error will display it.
So, paste something like this into notepad:
robocopy "c:\users\desktop\myDirectory" "\\MyServerName\MyBackupDestination" /i /e /y /z
pause
And save it as a .bat file, then run it!
More details of the Robocopy parameters which can be passed, including a retry section but I include the relevant part:
Retry options
/r:<N>
Specifies the number of retries on failed copies. The default value of N is 1,000,000 (one million retries).
/w:<N>
Specifies the wait time between retries, in seconds. The default value of N is 30 (wait time 30 seconds).
/reg
Saves the values specified in the /r and /w options as default settings in the registry.
/tbd
Specifies that the system will wait for share names to be defined (retry error 67).
EDIT
As per Rik's comment, the above is for copying. Both can be used to move (replace XCOPY
with MOVE
and for Robocopy it's more customised.
/S /MOV
or /E /MOV
will move the files/directories but you may end up with empty directories... If you want a 'cut and paste' like action, then use /MOVE
as this will remove the source directories and files when complete.
I'm going to assume that though you say "command line" you are willing to accept "works automatically in background." Let me present BitTorrent Sync. It works between any two+ points, continues if you run into timeouts and is easy to setup.
- Install on source, pick folder, copy key.
- Install on destination, pick folder, paste key.
- Watch as your files copy.
- Uninstall (or stop the folder on the source computer from syncing) and then delete the source files.
Only downside is that this doesn't work if you are in a place that blocks BitTorrent. In that case I would go with Gerbenny's suggestion and set up rsync.
Just to expand on to my own question:
I found the following options as well thanks to Dave's insight :)
RoboCop RoboCopy
RoboCop RoboCopy is a GUI skin and script generator for Robocopy.exe (Win NT Resource Kit). RoboCop RoboCopy is unlike any other robocopy script generator available.
What makes this one different? Well in a nut shell the ability to monitor the progress of the robocopy job. RoboCop RoboCopy allows for real time monitoring of all its running robocopy jobs with the inclusion of: - Current speed in MBs, - Completion time, & - Real time progress bar indication.
Better Robocopy GUI
Use a property grid to present all optional parameters. Provide a text editor to edit command line directly, and any change to the options in the text may be reflected back to the property grid, and vice-versa. Display immediate hints to an option highlighted in the property grid or in the text editor. Test-run the robocopy command line without opening Windows' command prompt. Some optional parameters of robocopy are exclusive or inclusive to each other, while some are the combination of others. The program may handle these scenarios properly.
With the copy command, you're looking for the /Y switch.
Though, I would recommend a more robust solution such as rsync for windows
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.
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.
Yes, it only deletes the file once it's finished copying.
You are correct -- Windows Move deletes only after a successful copy.
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.