4iT IT Support Sydney | Your Reliable Sydney IT Support Partner

Insights & News

Robocopy Wildcard Examples: Filtering Files by Name and Type

Robocopy uses two wildcard characters to filter which files it copies: the asterisk (*) matches any number of characters, and the question mark (?) matches a single character. Wildcards can only be used in the file name portion of the source, never in the folder path, and they go after the source and destination folders in the command.

Command prompt window on a Windows computer screen running a file copy.

Key facts

  • Robocopy syntax is robocopy <source> <destination> [files] [options], where [files] accepts wildcards.
  • The * wildcard matches any number of characters; the ? wildcard matches exactly one character.
  • Wildcards work only in the file name, not in the folder path; robocopy C:\Data\*\ ... will not work.
  • If no file filter is given, Robocopy defaults to *.*, meaning it copies everything.
  • Add /S or /E to apply the wildcard filter through subfolders as well as the top folder.

How do you use wildcards in a Robocopy command?

Wildcards go in the file filter position, which comes immediately after the source and destination folders. The structure is robocopy <source folder> <destination folder> <file filter> <options>. So to copy only PDF files from one folder to another, you would run:

robocopy C:\Source D:\Destination *.pdf

The asterisk before .pdf matches any file name, so every PDF in the source folder is copied. Note that the wildcard is in the file name only. You cannot put a wildcard in the folder path itself, for example to match multiple source folders, because Robocopy does not support wildcards in paths.

What is the difference between the * and ? wildcards?

The asterisk matches any number of characters including none, while the question mark matches exactly one character in that position. So *.txt matches every text file regardless of name length, but report?.txt matches report1.txt and reportA.txt but not report10.txt, because the single ? stands in for just one character. You can combine them. 2026-*.log matches every log file whose name starts with 2026-, which is a tidy way to grab a year's worth of dated files.

What are some common Robocopy wildcard examples?

The most useful patterns cover filtering by file type, by name prefix, and copying multiple types at once. Here are the ones we reach for most often:

  • robocopy C:\Source D:\Dest *.docx copies only Word documents.
  • robocopy C:\Source D:\Dest *.docx *.xlsx *.pdf copies Word, Excel, and PDF files in one pass (separate each filter with a space).
  • robocopy C:\Source D:\Dest invoice* copies every file whose name starts with "invoice", any type.
  • robocopy C:\Source D:\Dest *.log /S copies all log files from the folder and its subfolders.
  • robocopy C:\Source D:\Dest *.jpg /XF *thumb* copies JPEGs but excludes any file with "thumb" in the name.

That last one uses /XF (exclude files), which also accepts wildcards, handy when you want most of a file type but not a particular subset.

Why does a Robocopy wildcard sometimes return "Invalid Parameter"?

The most common cause of an "Invalid Parameter" error is putting the wildcard inside the source path instead of in the separate file filter position. Robocopy treats the first two arguments strictly as the source folder and destination folder, so a command like robocopy "C:\Backup\data_2026_*.bak" D:\Dest fails because the wildcard is buried in the source path. The fix is to give the folder as the source and put the wildcard pattern in the file filter position: robocopy "C:\Backup" "D:\Dest" data_2026_*.bak. We see this trip people up regularly, and it is almost always this path-versus-filter distinction.

Frequently asked questions

Can you use wildcards in the destination folder with Robocopy?

No. Wildcards work only in the file name filter, not in the source path or the destination path. The destination must be a specific folder. If it does not already exist, Robocopy creates it.

Does the wildcard filter apply to subfolders?

Only if you add /S or /E. By default Robocopy copies just the named files from the top-level source folder. Adding /S applies the same wildcard filter through subfolders (skipping empty ones), and /E does the same but includes empty subfolders too.

How do you copy multiple file types in one command?

List each wildcard pattern separated by a space in the file filter position. For example, robocopy C:\Source D:\Dest *.docx *.pdf *.jpg copies all Word documents, PDFs, and JPEGs in a single command.

What does Robocopy copy if you do not specify a wildcard?

If you omit the file filter, Robocopy defaults to *.*, which means it copies all files in the source folder. To copy everything including subfolders, combine that default with the /E switch.

Robocopy is the kind of tool that quietly does a lot of heavy lifting in the background of a well-run network. If you would rather have file moves, backups, and migrations handled properly rather than scripted on the fly, that is part of what we do for Sydney SMEs at 4iT as part of our business IT support service.

Brett Muscio

About the author

Brett Muscio is the Director of 4iT Support Pty Ltd, a managed services provider based in Castle Hill, NSW. He works with SME clients across Sydney, Melbourne, and Brisbane on Microsoft 365, cybersecurity, networking, backup and disaster recovery, and IT advisory, with on-site support across the Sydney metro area and remote delivery nationally. Connect on LinkedIn.

Scroll to Top