Skip to content

Instantly share code, notes, and snippets.

@TobiasPott
Created July 29, 2020 14:09
Show Gist options
  • Save TobiasPott/213a758d4bb7f91f7f91bfa5b0250756 to your computer and use it in GitHub Desktop.
Save TobiasPott/213a758d4bb7f91f7f91bfa5b0250756 to your computer and use it in GitHub Desktop.
echo off
if [%1]==[] (
echo No path given as parameter
exit /b
) else (
set basePath=%1
set imPath="C:\Program Files\ImageMagick\7.0.10-Q16-HDRI\magick.exe"
)
set folderPathTif=%basePath%*.tif
set folderPathPng=%basePath%*.png
REM set folderPathJpg=%basePath%"*.jpg"
REM set folderPathJpeg=%basePath%"*.jpeg"
set folders=(%folderPathTif%, %folderPathPng%)
REM for %%f in (%folderPathTif%, %folderPathPng%, %folderPathJpg%) do (
for %%f in %folders% do (
setlocal enabledelayedexpansion
set ext=%%~xf
REM ! indicated delayed expansion which causes the variable to contain the correct extension value
if "!ext!"==".png" (
echo PNG %%~nf
REM do not use specific compression
%imPath% "%%f" -channel RGBA -separate -resize 50%% -combine "%%f"
)
if "!ext!"==".tif" (
echo TIFF %%~nf
%imPath% "%%f" -channel RGBA -separate -resize 50%% -combine -compress lzw "%%f"
)
endlocal
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment