简体   繁体   中英

Jpegtran - Drag and drop batch file for multiple files

Is it possible to create a batch file capable of optimizing multiple images at once? Drag and drop multiple .jpg files on it? (and have the output be something like image1.jpg, image2.jpg, image3.jpg in a separated folder named "Optimized"?

If jpegtran is not the perfect tool for doing this, then I am open for any other suggestion. Maybe imagemagick is a better tool for this?

This code below allows you to drag and drop files onto it and then copies them to %userprofile%\\Desktop\\Optimized on your desktop.

@echo on
setlocal ENABLEDELAYEDEXPANSION
set "params=!cmdcmdline:~0,-1!"
set "params=!params:*" =!"
set count=0
for %%G IN (!params!) do (
  set /a count+=1
  set "item_!count!=%%~G"
  rem echo !count! %%~G
)
for /L %%n in (1,1,!count!) DO (
  xcopy "!item_%%n!" "%userprofile%\Desktop\Optimized"
)
pause
exit

Check out THIS LINK

I tested it on .jpeg and .png files apparently there is a limit of 2048 characters as well. see the link for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM