Let say I've many files named e.g.:

  • FirstIcon_16.png
  • FirstIcon_32.png
  • FirstIcon_colored_16.png
  • FirstIcon_colored_32.png
  • SecondIcon_16.png
  • SecondIcon_32.png
  • SecondIcon_colored_16.png
  • SecondIcon_colored_32.png

I want to convert those PNG images to multi layered ICO files at once. I can convert one set with same name to multi layered ICO with this command:convert *.png -alpha on -set filename:fname %t %[filename:fname].ico

So is there some way to create multiple ICO files at the same time fro. So output will be e.g.

  • FirstIcon.ico
  • FirstIcon_colored.ico
  • SecondIcon.ico
  • SecondIcon_colored.ico

What is proper way? To use somekind of for loop. or what?:

for f in *.png; do
  convert *.png -alpha on -set filename:fname %t %[filename:fname].ico

That for loop doesn't work ofc. But how I can do this kind task with bash? I'm not so familiar with bash commands so any help is very welcome.

  • If all your image groups look the same (same basic name in one group, all ending with _16.png, _32.png, ...), you can do something like for f in *_16.png; do b=$(basename $f _16.png); convert $b*.png -alpha on -set filename:fname %t %[filename:fname].ico; done. – ridgy May 10 '17 at 13:41
  • Thanks ridgy! It seems to work in my solution pretty well! So this is great answer. If you want to submit this in answer I can mark it to correct. – Sakari Niittymaa May 11 '17 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.