jargon

Why does this not cycle through full quotated arguments? (WinBatch)

May 7th, 2021 (edited)
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2.  
  3. echo TRK Build Tool
  4.  
  5. set compilerpath=C:\Program Files (x86)\FreeBASIC\fbc
  6.  
  7. if not exist "Revision History\" mkdir "Revision History"
  8. if not exist "Revision History\Compiler\" mkdir "Revision History\Compiler"
  9.  
  10. set stamp=%DATE% %TIME%
  11. set stampdate=%stamp:~4,10%
  12. set stamptime=%stamp:~-11,11%
  13. set stampdate=%stampdate:~-4,4%%stampdate:~-10,2%%stampdate:~-7,2%
  14. set stamptime=%stamptime:~0,2%%stamptime:~3,2%%stamptime:~6,2%%stamptime:~9,2%
  15. set stamp=%stampdate:~0,4%-%stampdate:~4,2%%stampdate:~6,2%-%stamptime:~0,2%%stamptime:~2,2%-%stamptime:~4,2%%stamptime:~6,2%
  16. echo DateTime: %stamp%
  17. set timestamp=%stamp%
  18.  
  19. setlocal enabledelayedexpansion
  20.  
  21. set argCount=0
  22. for %%x in (%*) do (
  23.    set /A argCount+=1
  24.    set "argVec[!argCount!]=%%~x"
  25. )
  26.  
  27. echo Project Ct: %argCount%
  28.  
  29. if %argCount%==0 goto :eof
  30.  
  31. for /L %%i in (1,1,%argCount%) do call :debug %%i !argVec[%%i]!
  32.     echo No.[%%i]: "!argVec[%%i]!"
  33.     set prjname=!argVec[%%i]!
  34.     echo Project No.[%%i] of %argCount%: %prjname%
  35. goto eof:
  36.  
  37. :debug
  38. echo Project No.%1: "%2"
  39. set prjname=%2
  40. if not %prjname%=="" (
  41.  
  42. tasklist /FI "IMAGENAME eq %prjname%.exe" 2>NUL | find /I /N "%prjname%.exe">NUL
  43. if "%ERRORLEVEL%"=="0" taskkill -f -im "%prjname%.exe"
  44.  
  45. "%compilerpath%" "%prjname%.bas" -s gui "rc\%prjname%.rc" > "Debug %prjname%.log"
  46.  
  47. if not exist "Revision History\Compiler\%prjname%\" mkdir "Revision History\Compiler\%prjname%"
  48.  
  49. cmd /c F | xcopy "Debug %prjname%.log" "Revision History\Compiler\%prjname%\Debug %timestamp%.log"
  50.  
  51. )
  52.  
  53. GOTO :eof
  54.  
Add Comment
Please, Sign In to add comment