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.
ExifTool is simply amazing and immensely powerful:
exiftool -if "$FrameCount > 0" -directory=Animated *.gif
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
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.