TFS Work In Progress Shelvesets

By now you all know that you should save your progress often. This batch file will quickly create a TFS shelveset with all your current changes. The shelveset will be named with the current date and time. You can specify an optional parameter which will be used as the comment for the shelveset. Be sure to use quotes around that comment if you have spaces in it.

echo off
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
for /f "tokens=1-3 delims=/:." %%a in ("%TIME%") do (set mytime=%%a%%b%%c)
set SHELVESET=wip_%mydate%_%mytime%

if [%1]==[] goto default
tf shelve %SHELVESET% /comment:%1 /noprompt
goto done

:default
tf shelve %SHELVESET% /comment:"Work in progress checkpoint" /noprompt
goto done

:done