Skip to content

Instantly share code, notes, and snippets.

@Kagee
Created June 18, 2023 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kagee/bf2a226dd93ce9f606c6e7832fe188e3 to your computer and use it in GitHub Desktop.
Save Kagee/bf2a226dd93ce9f606c6e7832fe188e3 to your computer and use it in GitHub Desktop.
@echo off
rem https://stackoverflow.com/a/5370380
rem Loop on multiple input files and auto
rem trim them using magick "!item_%%n!" -trim "!item_%%n!"
setlocal ENABLEDELAYEDEXPANSION
rem Take the cmd-line, remove all until the first parameter
set "params=!cmdcmdline:~0,-1!"
set "params=!params:*" =!"
set count=0
rem Split the parameters on spaces but respect the quotes
for %%G IN (!params!) do (
set /a count+=1
set "item_!count!=%%~G"
rem echo !count! %%~G
)
rem list the parameters
for /L %%n in (1,1,!count!) DO (
rem echo %%n #!item_%%n!#
magick "!item_%%n!" -trim "!item_%%n!"
)
rem pause
REM ** The exit is important, so the cmd.ex doesn't try to execute commands after ampersands
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment