Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Montreal, Quebec, Canada
    Posts
    256
    Thanks
    18
    Thanked 1 Time in 1 Post

    Windows 7 Batch File

    I would like to create a simple batch file, with a desktop shortcut, to copy several files from one drive to another. Not really worth the hassle of running a full blown copy of Window Backup or Acronis to do this. Is there a utility to create batch files in Win7
    David P - The Truth Is In Redmond

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    David,

    Are the files all in one directory? Do you want to copy all the files in that directory? Specifics needed.

    You create batch files using a text editor like Notepad.exe, builtin to Windows or NotePad++ free open source software.

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    Start with a DOS command so you know it works, then copy it into Notepad etc and save as MyCopyUtil.cmd or similar - leave the extension as "cmd" to make it a batch file.
    To test your DOS commands open a Command Prompt by right clicking on the Windows flag in the bottom left corner.

    cheers, Paul

  4. #4
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Montreal, Quebec, Canada
    Posts
    256
    Thanks
    18
    Thanked 1 Time in 1 Post
    I wish to copy 2 files from a folder on my desktop machine to a folder on a laptop. The two are in a homegroup. The desktop machine is directly connected to the router by an Ethernet cable and the laptop to the router by WiFi
    David P - The Truth Is In Redmond

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    David,

    As per Paul's instructions use this command twice in the file substituting the appropriate values:
    Code:
    Xcopy /Y "d:\path\sourcefilename.ext" "d:\destpath\*.*"
    Note: the /Y parameter suppresses the prompt for overwriting the files in the destination. If you want the prompt use /-Y

    HTH

    Edited per Graham's comment...good catch!
    Last edited by RetiredGeek; 2016-03-07 at 11:57.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  6. The Following User Says Thank You to RetiredGeek For This Useful Post:

    dpollock (2016-03-07)

  7. #6
    5 Star Lounger
    Join Date
    Dec 2009
    Location
    Delaware, US
    Posts
    1,172
    Thanks
    19
    Thanked 99 Times in 88 Posts
    Be aware that your path may contain spaces, in which case it will need to be in quotes.
    Graham Smith
    DataSmith, Delaware
    "For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)

  8. The Following User Says Thank You to gsmith-plm For This Useful Post:

    dpollock (2016-03-07)

  9. #7
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Montreal, Quebec, Canada
    Posts
    256
    Thanks
    18
    Thanked 1 Time in 1 Post
    Thanks. MANY years since I lived at the DOS prompt. As a matter of interest - why Xcopy instead of copy.
    David P - The Truth Is In Redmond

  10. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    David,

    It is my understanding that xcopy is more efficient and it does have more options. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. #9
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Montreal, Quebec, Canada
    Posts
    256
    Thanks
    18
    Thanked 1 Time in 1 Post
    I had completely forgotten about **** spaces in the command line!
    David P - The Truth Is In Redmond

  12. #10
    5 Star Lounger
    Join Date
    Dec 2009
    Location
    Delaware, US
    Posts
    1,172
    Thanks
    19
    Thanked 99 Times in 88 Posts
    XCOPY is more "robust" than COPY with more options. There is a newer Windows utility called ROBOCOPY (which stands for Robust Copy) but that may be more than you need.

    I use a third-party tool called HOBOCOPY for nightly automated jobs where the files that may be open or locked.
    Graham Smith
    DataSmith, Delaware
    "For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)

  13. #11
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,202
    Thanks
    49
    Thanked 987 Times in 917 Posts
    As you are copying to network machines you may be able to specify the path directly without having to map a drive.
    e.g. xcopy "d:\path\sourcefilename.ext" "\\PC2\sharedfolder\destpath\"

    cheers, Paul

    p.s. you don't need "*.*" on the destination, a trailing backslash is sufficient to indicate to xcopy that the destination is a folder.

  14. #12
    3 Star Lounger
    Join Date
    Sep 2001
    Location
    Montreal, Quebec, Canada
    Posts
    256
    Thanks
    18
    Thanked 1 Time in 1 Post
    That syntax worked just fine - once I got rid of embedded spaces
    David P - The Truth Is In Redmond

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •