Using Wildcards

Published by Marco on in Perforce

Perforce can interpret a rich wildcard syntax, but it can only be specified from the command line. An easy way to get to the correct directory is to do the following:

The following instructions apply to the Windows client (P4WIN) only.

  1. Right-click the desired starting folder
  2. Select Command Prompt from the shortcut menu

Now that you’re at a command prompt, you can use wildcards to open files for edit (or delete/revert, etc.). All of the standard symbols are interpreted as expected, with one additional operator “…”.

  • “.” is the current directory
  • “..” is one directory higher
  • “*” is zero or more characters
  • “?” is one character
  • “…” is all files in this directory and all files in all subdirectories

The path and directory names can be either those from the workspace (local) or those from the depot (server). In most cases, those are the same, but Perforce does not use implicit relative paths: you must preface all relative paths with “./” if you want Perforce to understand it should start looking from here.

Here are some examples:

p4 edit ./…*.txt
This edits all text files under the current directory; note the use of a filter (*.pas) for the “…” operator.

p4 integrate ./…/images/img*.png ./…/images/*_img.png
p4 delete ./…/images/img*.png

Rename all PNG files starting with “img” found within any sub-folder called “images” so that the img is at the end of the file instead of at the beginning.