@echo off
rem Open the selected file/dir in swarm
rem
rem P4V Custom Tool setup: Application: full path to this file,
rem check Add to context menus, Arguments: %D
set browser="C:\Program Files\Mozilla Firefox\firefox"
set swarmURL=https://swarm.perforce.com
set p4=p4
rem ----- end config
set arg=%~1
rem Directories are in local syntax - convert to depot syntax
set slashes=%arg:~0,2%
if "//"=="%slashes%" (
rem is depot syntax
) else (
for /F "usebackq" %%F in (`%p4% -ztag -F "%%depotFile%%" where "%arg%"`) DO (
set arg=%%F
)
)
rem strip off first "//"
set dpath=%arg:~2%
rem if a directory, strip "..." off the end
set dots=%dpath:~-3%
if "..."=="%dots%" set dpath=%dpath:~0,-3%
%browser% "%swarmURL%/files/%dpath%