Main Menu

Animation in images

Started by Who Me, September 10, 2021, 07:18:50 PM

Previous topic - Next topic

Who Me

Stumped I am.

Using Windows 10 64bit running exiftool(-k)

I desire to take a directory full of pictures and move all the non-static (animated) ones into a sub-directory.

Weeks ago I learned of the potential of exiftool to accomplish such a task when during my
research into how to rectify this problem, I stumbled upon the following solution written out:

exiftool -if "$FrameCount > 0" -directory=Animated *.gif

So for the last few days I have been actively pursuing trying to accomplish this but to absolutely no avail.

An additional problem is the many .webp files which I also wish to separate into an animated directory.
Looking at a webp file with exiftool, I see I would likely need to use:

"[RIFF]          AnimationLoopCount              : inf"

So I thought something along the lines of the following would work...

exiftool -if "$AnimationLoopCount=inf"' -directory=Animated *.*

But of course that didn't do the trick. I've tried so many variations of that line to discover the syntax needed
but have been thwarted every single time. Each new experiment based off something new found on the web
has met with the same disappointing result.

Can anyone give me a hint where I'm going wrong?

StarGeek

Quote from: Who Me on September 10, 2021, 07:18:50 PMI stumbled upon the following solution written out:
exiftool -if "$FrameCount > 0" -directory=Animated *.gif
So for the last few days I have been actively pursuing trying to accomplish this but to absolutely no avail.

In what way did this not work?  What was the response from exiftool?  My quick test with a multi-frame and a single frame gif worked here.  The single frame was not moved, while the multi-frame one was.  Also see below about use of the wildcard.

QuoteSo I thought something along the lines of the following would work...

exiftool -if "$AnimationLoopCount=inf"' -directory=Animated *.*

The problem here is that you are using the assignment operator =, which won't work in this context.  You would need to use either == for a numeric comparison or eq for a string comparison.  Because exiftool was written in Perl, you'll want to look over Perl operators for things like this.

But rather than check to see AnimationLoopCount is equal to inf, you could just check to see if the tag exists.  That is, unless you want to separate infinite loops from non-infinite ones as well:
exiftool -if "defined $AnimationLoopCount" -directory=Animated -ext webp .

Here I also used the -ext (-extension) option to limit processing to webp files and a dot to indicate the current directory.  With exiftool, it's better not to use something like *.* as you may end up processing files you don't want to (see Common Mistake #2b) and wildcards won't work at all if you need to recurse into subdirectories with the -r (-recurse) option.

All the above assumes you are using Windows CMD.  Using PowerShell or Mac/Linux requires swapping double/single quotes so that any option that contains a dollar sign, such as the -if option, is not interpreted as a shell variable instead of an exiftool one.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Who Me

Thanks for your prompt response. Turns out I had fallen into the old CMD PowerShell trap but
now thanks to you, I am free!

Plus I figured out how to use AnimationLoopCount variable. Turns out it is not a string but a
numeric.

exiftool -if '$AnimationLoopCount > 0' -directory=Animated *.*

or better yet according to your previous post:

  exiftool -if '$AnimationLoopCount > 0' -directory=Animated -ext webp .

So thanks greatly. Now I can sort-a-way to my hearts content.

Who Me

Just wish to add this in here, in case anybody is trying to do the same but is still encountering difficulties.

I have discovered (perhaps a well known fact to some better versed) that this hangs if there is a webp file which starts with a minus sign among the directory being sorted through.

Phil Harvey

If you use *.* instead of . as a filename argment then files beginning with minus signs will be interpreted as options on Mac/Linux unless you use -- to indicate the end of the options.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).