@echo off setlocal set WIN_DIR=%USERPROFILE%\StreamBase Workspace set SERVER_DIR=. set SB_PROJECT= set verbose=0 :loop_args if {%1}=={} goto :done_args set _this_arg=%1 set _this_arg=%_this_arg:"=% if not "%_this_arg:~0,1%"=="/" goto :done_args shift /1 if "%_this_arg:~0,1%"=="/" ( if /i "%_this_arg:~1,1%"=="w" (set WIN_DIR=%1& shift /1 ) if /i "%_this_arg:~1,1%"=="t" (set SERVER_DIR=%1& shift /1 ) if /i "%_this_arg:~1,1%"=="v" set verbose=1 if /i "%_this_arg:~1,1%"=="h" (call :usage & call :help & endlocal & goto :EOF) if "%_this_arg:~1,1%"=="?" (call :usage & call :help & endlocal & goto :EOF) ) goto :loop_args :done_args set SB_PROJECT=%1 if {%SB_PROJECT%}=={} (endlocal & echo No Project specified & goto :EOF) if not exist "%SERVER_DIR%" (endlocal & echo target "%SERVER_DIR%" does not exist & goto :EOF) rem convert relative path to absolute pushd %SERVER_DIR% for /f %%i in ('pwd') do @set SERVER_DIR=%%i popd if %verbose% lss 1 goto :createprj echo SB_PROJECT %SB_PROJECT% echo TARGET DIRECTORY %SERVER_DIR%\%SB_PROJECT% echo WORKSPACE DIRECTORY %WIN_DIR%\%SB_PROJECT% :createprj if not exist "%WIN_DIR%\%SB_PROJECT%" (endlocal & echo project %SB_PROJECT% does not exist & goto :EOF) if exist %SERVER_DIR%\%SB_PROJECT% goto OkServerProject :NoServerProject if %verbose% gtr 0 echo NO SERVER DIRECTORY, CREATING pushd "%SERVER_DIR%" md %SB_PROJECT% popd goto OkServerProject :OkServerProject pushd "%WIN_DIR%" cd %SB_PROJECT% for /d %%i in (*.*) do call :copydir "%%i" goto :donecopy :copydir pushd %1 if %verbose% gtr 0 pwd @copy *.* %SERVER_DIR%\%SB_PROJECT% > nul 2>&1 popd goto :EOF :donecopy rem all done popd endlocal goto :EOF rem Functions :usage echo Usage: sbflatten [/w ^] [/t ^] [/v] project >&2 goto :EOF :help echo. >&2 echo ^ ^ ^ ^ /w ^ >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ StreamBase Workspace directory echo ^ ^ ^ ^ ^ ^ ^ ^ Default: %USERPROFILE%\StreamBase Workspace >&2 echo ^ ^ ^ ^ /t ^ >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ Parent dir of project at target project dir >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ Default: current directory >&2 echo ^ ^ ^ ^ /v >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ Verbose mode >&2 echo ^ ^ ^ ^ project >&2 echo ^ ^ ^ ^ ^ ^ ^ ^ StreamBase Studio project to copy and flatten >&2 echo. >&2 echo sbflatten copies all files in an SBStudio workspace project to a single >&2 echo project directory created below the target directory. >&2 echo Creates project if it does not already exist in target. >&2 echo. >&2 echo Note: sbflatten does not know what the default workspace is for SBStudio goto :EOF