r/linuxquestions • u/yes-no-noise • 11d ago
Resolved Terminal command to search directory for all animated PNGs
I have a directory with thousands of files, many pngs, and a very small amount are animated pngs. I'm going to batch convert all the files to a different format, but doing so would break the animations on those few.
Is it possible to use find to search through the directory and write a list of only the pngs that are animated, so I can exclude them from the batch? How can you do that? Or is that too specific a property to search for with that command? What could I use instead then?
1
Upvotes
12
u/ipsirc 11d ago •
7
u/OneCDOnly 11d ago
TIL there are animated PNGs! 👍
1
u/ABG1YtBr 11d ago
Maybe using
file *would help? I'm not really sure if there's real differentiation from normal PNGs and animated ones, I don't even have a single file like this.-3
u/FreddyFerdiland 11d ago
no.
the two plans are
1a #!/bin/sh
COUNT=
file $1 | grep 'animat' |wc -lif [$COUNT < 1] exit;
convert $1
well that needs to be fixed fir the details..it assumes the file program reports the animation detail of png...otherwise fix it for a png command bthst does report file type
1.b or fix convert, eg add the option "-skipanim"...
2.. do as you asked, find every png upfront,
then
find path -name *.png | exec -n1 printifanimate.sh
where printifanimated.sh is a shell script which reads the png type and prints the file name if its animated,otherwise does nothing
3.. modify "find" to gave png type options
.