• XCopy Multiple File Extensions (XP)

    Author
    Topic
    #405969

    Is it possible to xcopy multiple file extensions with one line of code?

    As an example:
    xcopy “e:MyDirectory*.xls;*.doc” “Z:backup” /S /Y[tab ‘Note two different types of file extensions.

    As opposed to:
    xcopy “e:MyDirectory*.xls” “Z:backup” /S /Y
    xcopy “e:MyDirectory*.doc” “Z:backup” /S /Y

    I have not had any success.
    Thanks,
    John

    Viewing 1 reply thread
    Author
    Replies
    • #838512

      The syntax of the XCOPY command (do XCOPY /?) shows that this is not possible. You have to make two XCOPY commands. You can just have one line in your BATch file by doing something like:

      for %%x in (xls doc) do xcopy “e:MyDirectory*.%%x” “Z:backup” /S /Y

      (and note that the double quotes aren’t needed unless there’s a blank somewhere in the path). You could have reduced the previous line to:

      for %%x in (xls doc) do xcopy e:MyDirectory*.%%x Z:backup /S /Y

      This just generates the two original lines of code when it is run, but reduces the size of the BATch file.

      John

    • #838513

      The syntax of the XCOPY command (do XCOPY /?) shows that this is not possible. You have to make two XCOPY commands. You can just have one line in your BATch file by doing something like:

      for %%x in (xls doc) do xcopy “e:MyDirectory*.%%x” “Z:backup” /S /Y

      (and note that the double quotes aren’t needed unless there’s a blank somewhere in the path). You could have reduced the previous line to:

      for %%x in (xls doc) do xcopy e:MyDirectory*.%%x Z:backup /S /Y

      This just generates the two original lines of code when it is run, but reduces the size of the BATch file.

      John

    Viewing 1 reply thread
    Reply To: XCopy Multiple File Extensions (XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: