Batch process .png to .webp

You can do it with a help of a simple bash script.

Navigate to the directory where your images reside and execute this:

$ for file in *
> do
> cwebp -q 80 "$file" -o "${file%.png}.webp"
> done

You can change the output file name, as you want. But should end with a .webp extension.


You need to use GNU Parallel if you have that many, or you will be there all year!

Please copy a few files into a spare temporary directory first and try this there to be sure it does what you want before using it on 100,000 images:

parallel -eta cwebp {} -o {.}.webp ::: *.png

That will start, and keep running, as many processes as you have CPU cores, each doing a cwebp. The files processed will be all the PNG files in the current directory.

If the command line gets too long, you can pass the file list in using find like this:

find . -name "*.png" | parallel -eta cwebp {} -o {.}.webp

Tags:

Image

Bash

Png

Webp