none
Robocopy - wildcard in source

    Question

  • Hi,

    I am trying to make a robocopy where I need a wildcard in the source destination.

    Example: robocopy C:\*\*\Datasheet D:\Test\ *.pdf

    The overall folder structure is the same in D:\Test and I would like robocopy to copy the PDF files to the same folders in the destination.

    For example:

    C:\Test\Test1\test.pdf to D:\Test\Test1\test.pdf

    But it doesn't work.

    Is it even possible to use wildcards in source or destination?

    Thanks in advance.


    Friday, December 13, 2013 11:54 AM

Answers

All replies

  • Hi,

    Thanks for your posting.

    The source and destination parameters are specified as drive:\path or \\server\share\path. The file parameter can contain one or more literal file names, or it can use the familiar ? and * wildcards. Available options include dozens of switches that control copying, file selection, retry options, and the ability to create log files.

    For more and detail information about robocopy, please refer to:

    http://technet.microsoft.com/en-us/library/cc733145.aspx

    Regards.

    If you have any feedback on our support, please click here


    Vivian Wang

    Monday, December 16, 2013 2:46 AM
    Moderator
  • Hi Vivian,

    Thanks for the reply.

    Sounds good that * wildcards are supported.

    I have tried but I am getting an error:

    ERROR: Invalid Parameter #1


    robocopy "C:\Test\*\Data sheet" "D:\Test\*\Data sheet" *.pdf

    Monday, December 16, 2013 9:03 AM
  • Hi,

    Thanks for your posting.

    The robocopy command syntax as follow:

    robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

    Source:Specifies the path to the source directory.

    Wildcard characters could be used for the File selection options.

    Did you try to use this command:

    robocopy "C:\Test\Data sheet" "D:Test\Data sheet" *.pdf

    Regards.

    If you have any feedback on our support, please click here


    Vivian Wang

    Wednesday, December 18, 2013 6:07 AM
    Moderator
  • Hi,

    Thanks for your posting.

    The robocopy command syntax as follow:

    robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

    Source:Specifies the path to the source directory.

    Wildcard characters could be used for the File selection options.

    Did you try to use this command:

    robocopy "C:\Test\Data sheet" "D:Test\Data sheet" *.pdf

    Regards.

    If you have any feedback on our support, please click here


    Vivian Wang

    Hi Vivian,

    I am aware of the syntax.

    But the provided example will not work since "C:\Test\Data sheet" doesn't exist - I wanted to use the * instead, so that it would search in all the sub folders.

    Wednesday, December 18, 2013 9:43 AM
  • Wild cards can only be used in the source when they are used in the FileName.  They can not be used in the Path (folder names)
    Thursday, December 19, 2013 9:13 PM
  • robocopy "C:\Test\" "D:\Test\" .*pdf

    Above moves all PDF files

    or

    robocopy "C:\Test\" "D:\Test" "data sheets*"

    Above moves all files named Data Sheets regardless of the filetype.


    If it answered your question, remember to “Mark as Answer”.

    If you found this post helpful, please “Vote as Helpful”.

    Postings are provided “AS IS” with no warranties, and confers no rights.

    Friday, December 20, 2013 5:51 PM
  • Hi,

    I just want to confirm what is the current situation.

    Please feel free to let us know if you need further assistance.

    Regards.


    Vivian Wang

    Tuesday, December 24, 2013 8:11 AM
    Moderator
  • If you're trying to copy the directory structure when running the robocopy, try this:

    robocopy c:\test d:\test *.pdf /MIR

    From the robocopy syntax:

    /MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

    You could even just go with /E, but that won't delete old directories on later runs.

    Jason

    

    Jason A.

    Tuesday, December 24, 2013 2:26 PM