Jump to content


perforce and use of "wildcards+characters" in filename


  • Please log in to reply
5 replies to this topic

#1 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 25 April 2020 - 04:39 PM

The perforce system gives some examples of wildcard usage @ -

https://www.perforce....wildcards.html

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

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 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

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 26 April 2020 - 09:19 PM

The explanation about paths as strings very useful.
Thanks sambwise

Appreciate it

#4 holbrookged

holbrookged

    Newbie

  • Members
  • Pip
  • 1 posts
  • LocationHolbrook

Posted 20 May 2020 - 07:17 PM

So does // go one or two directory level down?

#5 engr.vns

engr.vns

    Advanced Member

  • Members
  • PipPipPip
  • 43 posts

Posted 19 June 2020 - 02:12 AM

// is the depot root
//... implies everything down from the depot root.

I assume your question was to control depth to two levels deep from your current directory using p4 notation.
I don't know...

I could not find examples to control depth -
https://www.perforce.../filespecs.html

#6 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 1192 posts

Posted 19 June 2020 - 05:32 AM

Since "*" doesn't match slashes, each "*/" is one level of "depth".

Hence, given these three files:

//depot/foo/bar
//depot/foo/baz
//depot/ola

which you could represent as a tree looking like this:

//depot/
	foo/
	   bar
	   baz
	ola

then here's the set of files that each of these wildcard expressions will match:

//depot/... -> "//depot/ola", "//depot/foo/bar", "//depot/foo/baz"
//depot/* -> "//depot/ola"
//depot/*/* -> "//depot/foo/bar", "//depot/foo/baz"
//depot/*/*/* -> (nothing)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users