We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

Writing a Batch File?

My knowledge is limited but wanted to ask:

Am I correct in thinking that you can write a batch file to copy all my docs from my docs to an external hard drive with just a click of a shortcut on my desktop? I am running windows 7.

If so, how do I go about doing this...and It would be great if the command would request to overwrite and previous filess with the same name.

Many many thanks for your help.
Regards,

Money Saver

«1

Comments

  • asc99c
    asc99c Posts: 134 Forumite
    You just need to use xcopy, something like the following:

    xcopy c:\documents and settings\username e:\backup /s/e/v/c/i/y

    Just stick this line into a text file and call it backup.bat or similar.

    I think on some versions of windows, Microsoft has now replaced xcopy with robocopy, so if xcopy doesn't work, try using robocopy instead. The flags at the end do the following;

    /s = copy subdirectories
    /e = copy empty subdirectories
    /v = verify copied files
    /c = continue on error
    /i = assume destination is a directory
    /y = suppress prompting for overwriting existing file
  • victor2
    victor2 Posts: 8,200 Ambassador
    Part of the Furniture 1,000 Posts Name Dropper
    It can be done with a batch file if you have some sort of understanding of good old DOS. You'd have to be pre-windows days for that.;)
    Basically you would use the xcopy command, something like:
    xcopy source destination /S/Y

    The /S switch tells it to include subdirectories and /Y tells it not to ask if overwriting existing files on the destination.
    Your source and destination would be the main parent directory you are copying from or to.
    You'd put that command into a text file with a .bat extension on your local drive and then create a shortcut to it on your desktop.

    In all probability you'd want to be a lot more sophisticated than just that command alone offers, but it would be a start.

    I’m a Forum Ambassador and I support the Forum Team on the In My Home MoneySaving, Energy and Techie Stuff boards. If you need any help on these boards, do let me know. Please note that Ambassadors are not moderators. Any posts you spot in breach of the Forum Rules should be reported via the report button, or by emailing forumteam@moneysavingexpert.com. 

    All views are my own and not the official line of MoneySavingExpert.

  • Col7777
    Col7777 Posts: 194 Forumite
    I have an external drive and I just drag whatever from the C: hardrive over to the external.
  • fwor
    fwor Posts: 6,888 Forumite
    Part of the Furniture 1,000 Posts Name Dropper
    Col7777 wrote: »
    I have an external drive and I just drag whatever from the C: hardrive over to the external.

    What happens when it encounters an existing file with the same name on the external drive?
  • Col7777
    Col7777 Posts: 194 Forumite
    Change the name, it gives you that option.
  • Lokolo
    Lokolo Posts: 20,861 Forumite
    Part of the Furniture 10,000 Posts
    Col7777 wrote: »
    Change the name, it gives you that option.

    Yes but that requires user interaction. Whereas in a batch file you can ignore any errors and it will continue. So if you had 500GB of files, which would require a number of hours. You could run the batch file and go make dinner :)
  • Or you could use Microsoft Sync Toy .
    4.8kWp 12x400W Longhi 9.6 kWh battery Giv-hy 5.0 Inverter, WSW facing Essex . Aint no sunshine ☀️ Octopus gas fixed dec 24 @ 5.74 tracker again+ Octopus Intelligent Flux leccy
  • Col7777
    Col7777 Posts: 194 Forumite
    You could make a folder on the external drive with the date then drag all that days files over to it, then the next time do another folder this may also make it easier to find a file plus you know when you did it for future reference.
  • GeoffX
    GeoffX Posts: 417 Forumite
    100 Posts
    You might like to have a look at AutoIt. It's free and allows you to create scripts that have a far greater range of functionality than Windows' own scripting.
  • asc99c wrote: »
    You just need to use xcopy, something like the following:

    xcopy c:\documents and settings\username e:\backup /s/e/v/c/i/y

    Just stick this line into a text file and call it backup.bat or similar.

    I think on some versions of windows, Microsoft has now replaced xcopy with robocopy, so if xcopy doesn't work, try using robocopy instead. The flags at the end do the following;

    /s = copy subdirectories
    /e = copy empty subdirectories
    /v = verify copied files
    /c = continue on error
    /i = assume destination is a directory
    /y = suppress prompting for overwriting existing file

    YAY!!! It worked! thanks so much!
    Regards,

    Money Saver

This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 352.3K Banking & Borrowing
  • 253.6K Reduce Debt & Boost Income
  • 454.3K Spending & Discounts
  • 245.3K Work, Benefits & Business
  • 601.1K Mortgages, Homes & Bills
  • 177.5K Life & Family
  • 259.2K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16K Discuss & Feedback
  • 37.7K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.