Article 4T8TV [SOLVED] Simple script for converting to images to webp - how to avoid double file extension?

[SOLVED] Simple script for converting to images to webp - how to avoid double file extension?

by
Grobe
from LinuxQuestions.org on (#4T8TV)
Hi.

I have made a simple but working sh script for converting png images to webp images using the cwebp command, because afaik the webp command itself can only handle one file at a time.

Code:#!/bin/bash
for i in *.png
do
echo ""
cwebp -z 9 "$i" -o "$i.webp"

# Make new file have same file-changed datestamp
touch -cm --reference="$i" "$i.webp"
echo ""
doneThis works very good, but every output file have this double file extension, for example "01.png" would be converted into "01.png.webp".

Do you guys have a neat way to solve this ?latest?d=yIl2AUoC8zA latest?i=UZ_JVSEWAeM:EBTtGFKBNX4:F7zBnMy latest?i=UZ_JVSEWAeM:EBTtGFKBNX4:V_sGLiP latest?d=qj6IDK7rITs latest?i=UZ_JVSEWAeM:EBTtGFKBNX4:gIN9vFwUZ_JVSEWAeM
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments