Raphael Rafatpanah
Raphael Rafatpanah

Reputation: 19997

How to Set Up & Use Jpegtran with Windows

I am a Windows user trying to get started with jpegtran and have not found a way to actually access the program. All questions I've found start at the command line, but when trying to duplicate the commands, I receive errors such as the following:

After viewing this question:

I tried to run these commands:

@echo none 
for /f "delims=" %%a in ('dir "*.jpg" /b /s /a-d') do (
echo processing "%%a"
"C:\Program Files\Image Optimization\jpegtran.exe" -optimize -progressive -copy none "%%a" "%%a.tmp"
move /Y "%%a.tmp" "%%a" >nul
)
pause

I get the error "%%a was not expected at this time."

My question is how to set up the folder structure for the images, jpegtran.exe file and the command prompt so that this command will run?

Upvotes: 4

Views: 5578

Answers (2)

foxidrive
foxidrive

Reputation: 41242

Your solution above looks to have correct format - but it is a batch file and you cannot paste it into a command prompt. Save the code in a text file, call it runjpg.bat and launch it in a folder with some jpg files to test. (Avoid calling the batchfile the same name as a command)

Upvotes: 5

LS_ᴅᴇᴠ
LS_ᴅᴇᴠ

Reputation: 11181

[Wrong information removed]

EDIT:

Sorry, didn't REALLY saw question!

This batch corrected will, for each jpg file found in current directory and subdirectories:

  • create a optimized file (suffixed .tmp)
  • replace original file with tmp file created.

Only requirement I see here is that you must have jpegtran.exe in C:\Program Files\Image Optimization folder!

Upvotes: 0

Related Questions