Jump to content

perforce and use of "wildcards+characters" in filename

  • Please log in to reply
2 replies to this topic

#1 engr.vns



  • Members
  • PipPip
  • 12 posts

Posted 25 April 2020 - 04:39 PM

The perforce system gives some examples of wildcard usage @ -


The p4 documentation shows use of -
1) "*" in current directory (not recursive)
2) filename "ending" in a specific extension in recursive directories.

Suppose a user wants to operate upon files in recursive directories but "wildcards+characters" need to be used in the filename

Example: user needs to revert all files named *spec1*.txt recursively.
Something as -
   sc revert ./.../*spec*.txt

Thanks in advance

#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1065 posts

Posted 25 April 2020 - 06:29 PM

If you think of whole paths as strings rather than as a series of discrete folder/file objects it's a lot easier to understand how Perforce wildcards work.  "..." matches any string (like the regex ".*") and "*" matches any string that does not include a path separator (like the regex "[^/]*").  The reason the * wildcard only matches within one directory is because spanning multiple directories requires including path separators in the pattern.  Simple as that!

So if you want to match all files that include spec1 in their name and end with .txt that would be something like:

...spec1*.txt (starting from the current directory)
//...spec1*.txt (everything under the depot root)

The "./" at the start is redundant, as is an expression like ".../*" unless you're very specifically trying to exclude files in the current directory and require that all matches be at least one level down (i.e. that they have at least one "/" in the relative path).

#3 engr.vns



  • Members
  • PipPip
  • 12 posts

Posted 26 April 2020 - 09:19 PM

The explanation about paths as strings very useful.
Thanks sambwise

Appreciate it

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users