Moving files unattended with cmd prompt

10,575

Solution 1

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.

Solution 2

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.

  1. Install on source, pick folder, copy key.
  2. Install on destination, pick folder, paste key.
  3. Watch as your files copy.
  4. 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.

Solution 3

Just to expand on to my own question:

I found the following options as well thanks to Dave's insight :)

RoboCop RoboCopy

enter image description here

http://sourceforge.net/projects/robocoprobocopy/

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

enter image description here

http://betterrobocopygui.codeplex.com/

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.

Solution 4

With the copy command, you're looking for the /Y switch.

Though, I would recommend a more robust solution such as rsync for windows

Share:
10,575

Related videos on Youtube

Jason
Author by

Jason

Updated on September 18, 2022

Comments

  • Jason
    Jason over 1 year

    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.

  • Rik
    Rik over 10 years
    Actually he was talking about "moving" not "copying" the files (I think OP used drag-and-drop). But i wouldn't want to move files via Windows if i'm not sure the move is done correctly so i also always use copy first. But ultimately Robocopy is the better way to go. It even has a move option if you really want. So +1.
  • Cruncher
    Cruncher over 10 years
    @Rik If you're moving locally on the same machine then I would advise against copying if you only need to move. Move and Copy are fundamentally different operations. Once has to copy all of the data, and one just has to edit the file allocation table to point some other reference to the data.
  • Rik
    Rik over 10 years
    @Cruncher I'm aware. And in case of moving files on the same volume/harddisk i would happily still use the MOVE-command. BTW You said on the same machine. That's not always true. If it's on a different harddisk the data still needs to be copied and it's not only an edit to the file-allocation. So i always make sure where i'm moving/copying to.