I have checked out few files on the perforce client. I can get the list of those files by command 'p4 opened' It gives path in the form of //depot/... like I want to know how this can be converted to path on the local path(I mean client path) So that i can create a batch file to backup those just before end of the Day Thanks In advance Uday
Check your p4 client as there you have defined the mapping for //depot to your filesystem path. Replace //depot with that to get a local path for a file so that you can backup.
I don't know how you can get that programmetically in a batch file.
p4 where filename
This is the command you're looking for.
It will list the depot path, client path and absolute path of the file on the local file system. Just pipe the output into cut
and pick the absolute path and copy them over.
You can use p4 where
to convert depot filespecs into local filespecs.
To parse the output of p4 where
from a Windows batch file, something like the following might help:
for /f "tokens=3" %%i in ('p4 where %my_depot_filespec%') do echo %%i
Note that the body of the for-loop may execute more than once for more complex mappings, such as the ones described in the p4 where
documentation. If you need to handle those, you might need to do more complicated parsing.
You also might want to consider why you feel the need to back up files at the end of each day oustide of using Perforce itself.
You may find that using a development branch and submitting the changes (with the "reopen for edit" flag checked) at the end of each day is actually easier and better. For a start, you are then using Perforce to keep track of your changes, rather than your own manual system.
Using a development branch means that you can do these checkins without risk of messing up your workmates.
Just a suggestion worth considering, that's all.
Following BAT script copies the perforce open files from a pending changelist
(%1 command line argument)
p4 opened -c %1 > open-%1.txt
for /F "tokens=1 delims=#" %%i IN (open-%1.txt) do call :add-to-zip %%i
:add-to-zip
for /F "tokens=3" %%j IN ('p4 where %1') do zip [zip-file-name] %%j
Thanks a ton :-) Was just searching for the command which can give me the client path of the opened files exactly for the same reason of backing up the files. Not just I got the command, but the script too :-)
This batch script can zip files into individual change list. for /F "tokens=1,5,6 delims=# " %%a IN ('p4 opened') do for /F "tokens=3" %%j IN ('p4 where %%a') do zip %%b%%c %%j
It will create files like this: change571620.zip change673450.zip change723098.zip defaultchange.zip
This batch script can zip files into individual change list.
for /F "tokens=1,5,6 delims=# " %%a IN ('p4 opened') do for /F "tokens=3" %%j IN ('p4 where %%a') do zip %%b%%c %%j
It will create files like this:
change571620.zip
change673450.zip
change723098.zip
defaultchange.zip