6

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?

Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
monthon1
  • 245
  • 3
  • 10
  • 1
    Have you read: http://stackoverflow.com/questions/1412529/how-do-i-programmatically-check-whether-a-gif-image-is-animated ? This may not be possibly just from the shell... – fredley Sep 20 '10 at 15:03
  • @TomMedley Everything is possible "just from the shell". (inb4 "then where's my `./cure4cancer.sh`") – Camilo Martin Feb 05 '16 at 09:53

1 Answers1

11

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
Ivo
  • 3,481
  • 1
  • 25
  • 29