Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine if a gif is animated?

I have large number of files with .gif extension. I would like to move all animated gifs to another directory. How can I do this using linux shell?

like image 557
monthon1 Avatar asked Sep 20 '10 14:09

monthon1


1 Answers

Basically, if identify returns more than one line for a GIF, it's likely animated because it contains more than one image. You may get false positives, however.

Example use in shell:

for i in *.gif; do
  if [ `identify "$i" | wc -l` -gt 1 ] ; then
    echo move "$i"
  else
    echo dont move "$i"
  fi
done
like image 188
Ivo Avatar answered Sep 18 '22 14:09

Ivo