2

I have added convert %f %f.png to Thunar's custom actions to convert a selected image to png.

What would be the command that can be added in the same way that would allow selecting multiple files or an entire folder for the same purpose?

2 Answers2

1

That is really easy:

mogrify -format png %N

Note the capital N.

aquaherd
  • 6,345
1

I use Thunar to convert multiple svg files to various PNG files - mainly used as icon files for the Xubuntu desktop environment.

For this I created a script, based on another script I found somewhere. As this script converts a set of selected images files into other image files, which might help you as well. Here is what I did to get this working in Thunar;

  1. Start Thunar as root; go to terminal, type "sudo thunar"
  2. Navigate in Thunar (Root) to the /usr/bin directory on your system disk
  3. Create a new document there, and name it something simple (e.g. convertPNG)
  4. paste the following text in the document:
#!/bin/sh

mkdir -p ./64/ mkdir -p ./96/

for file do if [ ! -e "$file" ] then continue fi name=$( echo $file | cut -f1 -d.) convert -density 108 -background none $file ./64/${name}.png convert -density 144 -background none $file ./96/${name}.png done

  1. Save the file.
  2. Right click the file in Thunar, and change the permissions in the "properties" dialogue to make the file executable
  3. Close Thunar (the Root session)
  4. Open Thunar and navigate to the custom actions menu
  5. Create a new custom action and call that e.g. "Convert to PNG"
  6. As the command, type "convertPNG 64 96 %N"
  7. Don't forget to set the correct Appearance Conditions (in my case, "image files" and *svg;*SVG)

This will convert the image file (in my case, the svg file) into two PNG files, one with size 96x96 and one size 64x64, into two separate directories.

With a bit of tweaking, you can use this script to suit your own wishes (e.g. not changing the size, creating various directories for the files) etc.Just change the script I pasted above, and play around with it a bit.

Treepata
  • 257