0

First command find and list jpeg/gif files with png extension. Second command convert a file to png.

  1. find . -type f -name "*.png" | xargs -L 1 -I{} file -i {} | grep -v 'image/png; charset=binary$'

  2. find . -name "*.jpg" -exec mogrify -format png {} \;

I to combine these two commands.

1 Answer 1

2
find . -type f -name '*.png' -exec bash -c '[[ "$(file -bi {})" != "image/png; charset=binary" ]] && mogrify -format png {}' \;

This command will find regular files with a png extension, and then execute mogrify -format png on every file if the mime doesn't match "image/png; charset=binary".

You must log in to answer this question.

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