@echo off setlocal EnableExtensions EnableDelayedExpansion if "%~1"=="" goto usage if "%~2"=="" goto usage if "%~3"=="" goto usage set "SRC=%~1" set "OUT=%~2" set "ANGLE=%~3" if not "%ANGLE%"=="90" if not "%ANGLE%"=="180" if not "%ANGLE%"=="270" goto bad_angle if not exist "%SRC%\" goto no_src where magick >nul 2>nul if errorlevel 1 goto no_magick if not exist "%OUT%\" mkdir "%OUT%" set /a COUNT=0 set /a FAIL=0 for %%E in (jpg jpeg png bmp tif tiff) do ( for %%F in ("%SRC%\*.%%E") do ( if exist "%%~fF" ( set "TARGET=%OUT%\%%~nF%%~xF" if exist "!TARGET!" ( echo Skip: %%~nxF ) else ( magick "%%~fF" -rotate %ANGLE% -strip "!TARGET!" if errorlevel 1 ( echo Failed: %%~nxF set /a FAIL+=1 ) else ( echo Done: %%~nxF set /a COUNT+=1 ) ) ) ) ) echo Rotated: %COUNT% Failed: %FAIL% exit /b 0 :usage echo Usage: %~nx0 "source_folder" "output_folder" 90 exit /b 2 :bad_angle echo Angle must be 90, 180 or 270. exit /b 2 :no_src echo Source folder not found: %SRC% exit /b 2 :no_magick echo ImageMagick not found. Install it with: winget install ImageMagick.ImageMagick exit /b 2