Batch Files (.bat and .cmd)
Some batch file examples and similar scripts (e.g. WSH) for Windows (mostly).
-
An incredible collection of batch files: http://www.robvanderwoude.com/index.html
-
errorlevel 0 - almost universally success. traditionally > 0 was an error. but some utilties return negative values for errors! "NEQ" is your friend.
-
SET newvar=abc - do NOT put spaces around the equal sign, that is NOT the SET syntax. (very bizarre, variable will be listed when you type SET)
-
FOR /f "delims=" %%i in (redo-list.txt) DO ( ... ) -- do NOT put quotes around the file name - quotes are an entirely different thing in FOR.
-
Runs ffmpeg on every .mov file in the current folder ( likely to lose formating in the save, based on - https://stackoverflow.com/a/24273691/2391738 ) : FOR /F "tokens=*" %G IN ('dir /b *.mov') DO ffmpeg -i "%G" "%~nG.mp4"
-
PAUSE - is built in pause (not sure when added)(stops and waits for key to continue)
-
Sleep for x seconds - nothing built in as of Win10 - either 3rd party or hack ping for 30 seconds: PING -n 31 127.0.0.1>nul
tags: script, batch, .cmd, .bat, automate
>>
Leonard Chan's Homepage
>>
Scribble Web
>> Batch Files (.bat and .cmd)