Thursday, September 4

Iterate.bat



REM Make a copy of this batch file before modifying.

SetLocal EnableDelayedExpansion

@echo on

REM When a podcast cover file (bc###.png) is passed to this script, a series of thumbnail files for YouTube are created, each one smaller, until one that is under 2 gigabytes that YouTube will accept, is generated.

REM The thumbnail image files are saved in this folder: C:\Users\livec\Downloads\ 

If Not Exist "%1" Then (Choice /m "File does not exist. Press Ctrl+C")

Title %~nx1

For /l %%i In (1280, -100, 1000) Do (
REM    Echo %%i
	C:\ffmpeg\ffmpeg -y -i "%~dp1%~nx1" -vf scale=%%i:%%i "C:\Users\livec\Downloads\%~n1_%%ix%%i.png"

	Set n="C:\Users\livec\Downloads\%~n1_%%ix%%i.png" 

REM	Echo n = !n!

	for %%f in (!n!) do (
		Set /a FileSize=%%~zf
		Echo %%~nxf  FileSize = %FileSize%
		If !FileSize! LEQ 2097152 (
			GoTo FileLessThan2Megabytes
			)
		)
	)

:FileLessThan2Megabytes

rundll32.exe cmdext.dll,MessageBeepStub
rundll32 user32.dll,MessageBeep

Choice /d N /t 99

EndLocal