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,220
  • this will convert all selected files to png with the same names, keep the source files, output in the same folder –  Jan 30 '13 at 23:44
  • have you an idea on how to adapt for an analog purpose a command like avconv -i %f %f.mp3 so that instead of converting a selected file would convert all selected (but one after the other, to avoid eating up the CPU) -- ? i've even set a bounty –  Apr 30 '13 at 09:08
  • 1
    avconv does not support multiple files per input. You will need to either find another tool that does or write a shell script that will feed avconv one by one. – aquaherd Apr 30 '13 at 12:21
  • yes, if someone would provide me with a script, i would gladly take that as an answer :) -- would you please add that info as comment to the specific question? i should edit that in order not to ask what's impossible. or maybe there's some other tool than avconv/ffmpeg that would support multiple files –  Apr 30 '13 at 12:23
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
  • 247
  • 2
  • 11
  • Thanks for posting this script. Here's an easier way to get the basename of a file without the extension: http://stackoverflow.com/questions/2664740/extract-file-basename-without-path-and-extension-in-bash. Note that you will have to set the script to #!/bin/bash though. – Glutanimate Sep 06 '13 at 16:18