I have a folder with lots of images and i want to sort animated GIFs from non animated GIFs and move the animated GIFs to a new folder. Tried with software like XnView and XnViewMp for Windows but they don't have this option [ http://newsgroup.xnview.com/viewtopic.php?f=82&t=31485 ]. Also tried this: How divide a folder of GIFs into animated and static ones but the Image Magic command is for one image only and there are too many files to do that one by one.

3 Answers 3


ExifTool is simply amazing and immensely powerful:

exiftool -if "$FrameCount > 0" -directory=Animated *.gif
  • Awesome! It does the job very easy. Commented Apr 15, 2015 at 4:30
  • Yeah, it's great, isn't it? I've been using it for a long time (mainly to edit/delete JPEG metadata) and still discover new features and uses regularly. Also the developer (a nuclear physicist and programmer) is extremely helpful so if you face any difficulties just post on the forum (or here on SU :).
    – Karan
    Commented Apr 15, 2015 at 6:03

To filter out the animated GIFs, you need to search for GIF files with more than one frame. Each frame starts with a "Graphics Control Extension" block with the hexadecimal signature 21 F9 04. So you have to search for .gif files with two or more occurrences of this signature. These should be typically animated GIFs.

This general approach should work with any tool which supports some kind of binary search together with wildcards. This also means that many tools with regular expression support should find animated gif files with this expression:

  • At first I tried my favorite file manager Total Commander, but sadly the provided regex engine doesn't support multi-line search and it doesn't work.
  • Swiss File Knife (sfk): find all animated GIFs on drive C:
    sfk xfind -firsthit -pat "/\x21\xf9\x04[4 bytes]\x00**\x21\xf9\x04/" -dir c:\ -file .gif | findstr ":file"
  • FreeCommander supports the above regex in his "Search files" dialog (advanced mode)
  • PowerGREP also finds animateds GIFs with the options "Search through binary files" and "Dot matches newlines"
  • Grep for Windows: grep -Pl "(?s)\x00\x21\xf9\x04.*\x00\x21\xf9\x04" *.gif
  • That regex for Swiss File Knife doesn't find all the animated GIFs. I went on to delete all animated GIFs in that folder with: sfk xfind -firsthit . "/\x00\x21\xf9\x04[4 bytes]\x00**\x21\xf9\x04/" +del -yes | findstr ":file" but there are some GIFs files remaining that are animated. Didn't tried FreeCommander and PowerGREP because they are not free software and didn't got any quick results with Grep for Windows or GrepWin (I don't know how to grep). Commented Apr 14, 2015 at 20:02
  • Also very important using that expression in a folder that has other types it returns files like .exe or .dll. So i guess it's not exclusive for GIF files. Commented Apr 14, 2015 at 21:56
  • @Ventolinmono You can just add a file pattern the sfk command to search only for .gif files. Of course FreeCommander is free, that's why it called like it is. For grep the answer has a working example, so I don't see why you don't know how to use it.
    – splash
    Commented Apr 15, 2015 at 6:57
  • @Ventolinmono It's not unusual that the regular expression pattern is also found in other binary files. That's why you should use a file mask.
    – splash
    Commented Apr 15, 2015 at 7:13

This may different than what you are looking for, but it works simply enough: Use an image viewer such as FastStone Image Viewer available at (I use the portable version.):


Make a folder for the motion gif images.

Observe the gif images in the viewer to easily differentiate between motion and non-motion gifs. As you go through the images with the viewer select the gif images in Windows File Explorer using Shift + Right Click for each motion gif.

When you are done selecting all the motion gif images use Ctrl + X to cut then go into your motion gif folder and use Ctrl + V to paste them into the folder.

That's it, although it is also a good time to get rid of some obsolete images.


You must log in to answer this question.

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