0

I need to execute often the following command which compresses all the PNG files in a folder:

for %i in (*.png) do pngout.exe "%i" /kp

So I have added this command in a file png.cmd and added the folder to the system PATH.

However when I execute the command (png.cmd) from a point in my file system, I get the following error:

C:\Users\Desktop>png  
i" /kp was unexpected at this time.

Is there a way to fix this problem, also I'm thinking where the shell is going to execute the png.cmd command ? In the path where I've created the png.cmd file ? I'd need to execute it in the current PATH where I'm with the shell.
Any idea? Thanks a alot

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Max Korn
  • 275
  • 7
  • 18

1 Answers1

2

Your syntax error is caused by using only 1 % in your for loop variable, when you use a batch file you need to use 2 to escape the first one.

for %%i in (*.png) do pngout.exe "%%i" /kp

With regards to your path question, fix this first, then see if it's still an issue.

Bali C
  • 30,582
  • 35
  • 123
  • 152