locked
Copying a directory and its contents through a batch file. RRS feed

  • Question

  • Hi, by directory I mean H:\New Folder\New 1\Content\DCIM2014 Images\Artworks

    I want to copy the folder 'Artworks' plus its contents to a specific folder in other drive (say E:\pptx for this i created a batch 

    mkdir E:\pptx
    xcopy /s H:\New Folder\New 1\Content\DCIM2014 Images\Artworks E:\pptx

    but its not doing anything.

    please help.. 

    Tuesday, November 11, 2014 2:09 PM

Answers

  • mkdir E:\pptx

    xcopy /s H:\New Folder\New 1\Content\DCIM2014 Images\Artworks E:\pptx

    but its not doing anything.

    please help.. 

    When you run batch files then it is imperative to invoke them from a Command Prompt (cmd.exe) during the testing phase. You will then see exactly what the command does. In your case you would have seen an error message because you omitted some double quotes. Here is the correct command. You do not need the mkdir command.

    xcopy /s /y "H:\New Folder\New 1\Content\DCIM2014 Images\Artworks"  E:\pptx\


    • Edited by Frederik Long Tuesday, November 11, 2014 2:21 PM
    • Proposed as answer by Mike Laughlin Tuesday, November 11, 2014 2:21 PM
    • Marked as answer by Bill_Stewart Friday, December 5, 2014 11:09 PM
    Tuesday, November 11, 2014 2:20 PM

All replies

  • mkdir E:\pptx

    xcopy /s H:\New Folder\New 1\Content\DCIM2014 Images\Artworks E:\pptx

    but its not doing anything.

    please help.. 

    When you run batch files then it is imperative to invoke them from a Command Prompt (cmd.exe) during the testing phase. You will then see exactly what the command does. In your case you would have seen an error message because you omitted some double quotes. Here is the correct command. You do not need the mkdir command.

    xcopy /s /y "H:\New Folder\New 1\Content\DCIM2014 Images\Artworks"  E:\pptx\


    • Edited by Frederik Long Tuesday, November 11, 2014 2:21 PM
    • Proposed as answer by Mike Laughlin Tuesday, November 11, 2014 2:21 PM
    • Marked as answer by Bill_Stewart Friday, December 5, 2014 11:09 PM
    Tuesday, November 11, 2014 2:20 PM
  • Hi,

    What do you mean by 'its not doing anything'?

    This isn't a scripting question, it's really about how to use xcopy (hint: trailing slash or /I and path issues):

    http://ss64.com/nt/xcopy.html

    Try robocopy in the future:

    http://ss64.com/nt/robocopy.html


    EDIT: Slow on submit, see above.

    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Tuesday, November 11, 2014 2:20 PM
  • Many thanks it worked :) 

    Tuesday, November 11, 2014 3:36 PM