Branching work in progress

Perforce Knowledge Base: Branching work in progress shows how you branch work in progress.

Comments are mine. The commands are from Perforce with no known edits.
When I see strings hard coded, I want to abstract them into variables.
Maybe,
VCFOLDER=//depot
PROJECT=/project
LABELTAG=home
STREAMIN= < could be main/qa/QA a defined branch point.
STREAMOUT=work-project
LOCALIN=c:\app-src\project
LOCALOUT=c:\app-src\work-project

So this

p4 integ -v //depot/project/...@home //depot/work-project/...
xcopy/s/i $LOCALIN $LOCALOUT c:\app-src\work-project

would be

p4 integ -v $VCFOLDER$PROJECT...@$LABELTAG $VCFOLDER$STREAMOUT...
xcopy/s/i c:\app-src\project c:\app-src\work-project

REM Notice the use of the @home.
REM work-project is a new VCS folder.

p4 integ -v //depot/project/...@home //depot/work-project/...

REM Submit essentially a "private branch?"

p4 submit //depot/work-project/...

REM At this point can't we just do a rmdir and a p4 sync -f?
REM Xcopy is awesome. /i stops the question about file or directory.

xcopy/s/i c:\app-src\project c:\app-src\work-project

REM Now we cheated the P4S from making us do a lot of work.
REM Like we don't have a client or even about our xcopy.
REM So the flush command seems to do a jedi mind trick on P4S.
REM Flush is really a p4 sync -k that bypasses the client update.
REM Otherwise your files would be deleted

p4 flush //depot/work-project/...

REM Find any files that you deleted from your work in progress.
REM These files won't be in the new branch unless you work around deleted revisions later.
REM Using the default change list add all deleted files. -status deleted locally

p4 diff -sd c:\app-src\work-project... | p4 -x - delete

REM Using the default change list add all edited files. -status edited locally

p4 diff -se c:\app-src\work-project... | p4 -x - edit

REM Using the default change list add all edited files. -status added locally

dir/s/b c:\app-src\work-project | p4 -x - add

REM I will need to add a chdir here. They noted it but not in the script.
REM Finally we committed the new branch, checked that everything was well?
REM Some kind of pause for review or missing function.
p4 revert //depot/project/...

Final comments, the above is just an example. To make it work in a real development team would require some parameters at least. Also, it leaves as an exercise to the reader to create the workspace for the branch.