@echo off setlocal EnableExtensions EnableDelayedExpansion rem Adjust these to your install directories set WMCMD=c:\util\wmcmd.vbs set OUTDIR=%USERPROFILE%\Videos\Zune rem Default to *.avi set MASK=%1 if x%1x==xx set MASK=*.avi rem Make the output directory if it's not already there if not exist %OUTDIR% md %OUTDIR% rem Loop through the files that fit the mask for %%F in (%MASK%) do ( set targ=%%~nF set targ=!targ:,=! set targ=!targ:'=! echo Encoding %%F to %OUTDIR%\!targ!.wmv call :makevid "%%F" "%OUTDIR%\!targ!.wmv" ) goto end :makevid rem use WMCmd to determine the actual dimensions of the video for /f "tokens=2" %%x in ('cscript "%WMCMD%" -input "%1"^|findstr Width') do ( set WIDTH=%%x ) for /f "tokens=2" %%x in ('cscript "%WMCMD%" -input "%1"^|findstr Height') do ( set HEIGHT=%%x ) echo Input is %WIDTH%x%HEIGHT% set /a SCALEX=1024 * %WIDTH% / 320 set /a SCALEY=1024 * %HEIGHT% / 240 if %SCALEX% GTR %SCALEY% ( set /a NEWX=1024 * %WIDTH% / %SCALEX% set /a NEWY=1024 * %HEIGHT% / %SCALEX% ) else ( set /a NEWX=1024 * %WIDTH% / %SCALEY% set /a NEWY=1024 * %HEIGHT% / %SCALEY% ) rem convert to divisible by 4? set /a NEWX=%NEWX% / 4 set /a NEWX=%NEWX% * 4 set /a NEWY=%NEWY% / 4 set /a NEWY=%NEWY% * 4 echo Converting to %NEWX%x%NEWY% cscript "%WMCMD%" -input "%1" -output "%2" -v_width %NEWX% -v_height %NEWY% -v_profile MP -v_bitrate 768000 -a_setting 128_48_2 goto :eof :end endlocal