4

I'm doing

convert dead0000.bmp -alpha on -fill none -draw 'color 0,0 replace' dead0000.png

but I have a few thousand files. Is there any way to just do the whole directory at once?

2 Answers 2

3

A simple for loop in Bash, macOS' default shell, would suffice:

for f in *.bmp; do convert "$f" -alpha on -fill none -draw 'color 0,0 replace' "${f%%.bmp}.png"; done

It uses string manipulation to replace the file extension for the output file. Here:

  • "$f" is the original input filename
  • "${f}" is the same, just a different way of accessing the variable
  • "${f%%.bmp}.png" uses string replacement – f%%.bmp means, delete the longest match of .bmp from the back of $f.
8
  • What is 0,0 ? Commented May 30, 2017 at 7:54
  • @IulianOnofrei I don't know; it was part of the OP's command. You should ask him. It'd be great if you could explain why you downvoted the post.
    – slhck
    Commented May 30, 2017 at 9:05
  • But if you look at the documentation, it says: “In this coordinate system 0,0 is the center of the top-left pixel”.
    – slhck
    Commented May 30, 2017 at 9:08
  • I downvoted it because it doesn't explain the command at all. Since not all people have the exact same question, they need to adapt the answers. Also, where is the color that needs to be replaced in that command? Commented May 30, 2017 at 9:10
  • @IulianOnofrei The question is about how to batch-run a particular command. In this case it doesn't matter if it's an ImageMagick command or if some other tool is used. The job of an answer shouldn't be to explain what a command does, when it is already given in the question, and that question is not about the actual functionality of the command. I do realize sometimes people find questions related to their problems, but with a different focus. This is one such question. If you have a problem understanding the command, please read the documentation and ask a new question instead.
    – slhck
    Commented May 30, 2017 at 9:15
0

have a look at this. mogrify is a powerful scripting tool for imagemagick http://www.imagemagick.org/script/mogrify.php (and *.bmp)

1
  • Please add more than just a link as an answer. While it might be helpful, we would like the actual answer here, on Super User. Especially if the OP is asking for a command, you should be able to give some solution. Thanks
    – slhck
    Commented Jun 26, 2014 at 16:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .