You are not logged in.


I'm trying to convert all the WebP files in a folder to JPEG files using a Thunar custom action.
#!/bin/bash
for f in ./*.webp; do
if [ -f "$f" ]; then
basefilename="${f%.*}"
newfilename="${basefilename}.jpg"
if [ ! -f "$newfilename" ] ; then
printf "Converting %s to %s " "$f" "$newfilename"
convert -quality 55 "$f" "$newfilename"
if [ -f "$newfilename" ]; then
rm $f
printf "...... Done!! \n"
fi
else
printf "\n !!!File $s already exists !!!\n" $newfilename
continue
fi
fi
done
exit 0
source: https://www.thechubbyengineer.com/compu … es-to-jpg/
Can you help me?
Last edited by bigbadaboum (2026-06-15 19:16:40)
Offline


Thunar custom actions work on mimetypes, like folder or image/webp. This means if you want to work on folders containing webp images and webp images directly, you'll need two separate custom actions.
Custom Action #1 - folders containing webp images
Create a script with the following content (and make it executable):
#!/usr/bin/env bash
for F in $@; do
for f in "$F"/*.webp; do
basefilename="${f%.*}"
newfilename="${basefilename}.jpg"
convert -quality 55 "$f" "$newfilename"
rm "$f"
done
doneIn the custom action, set the command to point to this script followed by "%F"
On the appearance tab, select "Directories"
To make it work, right-click on one or more directories containing webp files and select this custom action.
Custom Action #2 - webp image files
Create a script with the following content (and make it executable):
#!/usr/bin/env bash
for f in $@; do
basefilename="${f%.*}"
extension="${f##*.}"
newfilename="${basefilename}.jpg"
if [ "$extension" == "webp" ]; then
convert -quality 55 "$f" "$newfilename"
rm "$f"
fi
doneIn the custom action, set the command to point to this script followed by "%F"
On the appearance tab, select "Images"
To make it work, right-click on one or more webp files and select this custom action.
Last edited by ToZ (2026-06-15 19:14:51)
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Your two tutorials work perfectly for me, thank you very much.
Offline


Congrats on solving the issue above.
Interested in the unspoken subtext of this topic. Why convert webp to jpg? Just interested to know out of curiousity, Because I thought webp has better quality for its lossy compression when compared to jpg. Assuming its a support based thing, I believe support for jpg is more widespread but i could be wrong, and dont want to assume. Just wondering if I'm missing something important (not online much these days due to modem issue).
No LLM was used in the production of this post
Offline
[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 534.44 KiB (Peak: 535.41 KiB) ]