Reputation: 625
I need to get the local path of a depot file, for example:
input: //MyDepot/MyBranch/my file.txt
output (mac): /Volumes/p4/MyDepot/MyBranch/my file.txt
or:
output (windows): F:\p4\MyDepot\MyBranch\my file.txt
both 'p4 have' and 'p4 where' produce parse-unfriendly output, including mapping info I don't need. Is there a p4 command for that simple task?
Upvotes: 2
Views: 1856
Reputation: 44
Very close, Samwise. I would have made this a comment on the main answer, but not enough rep yet, sorry.
To prevent Windows from expanding the environment variable, both percents need to be carrot escaped, and that part of the expression must not be in quotes.
example: p4 -ztag -F ^%change^%,^%time^%,^%path^% changes -m 3
example from 2020/4/2: https://community.perforce.com/s/article/15148
Upvotes: 0
Reputation: 3332
On a non-Windows OS, Run:
p4 -ztag -F %path% where <depotFilePath>
This will give you the one-liner with only the local path.
On Windows, %path% expands to the system environment path so this only works on non-Windows systems.
The -F is a client-side option, so if you don't have it, you may need to update your p4 binary. If you don't have it, and can't update the binary, you can also just run p4 -ztag where <depotFilePath>
.
You'd get back easy to parse output. The key is path
to get the local path to the file.
The output will look like:
... depotFile //depot/a
... clientFile //gabe/a
... path /Users/gabe/tmp/a
Upvotes: 4