Page 1 of 1

Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-12T23:00:03-07:00
by IMuser1
How could you used this command
mogrify -format jpg *.png

But to only mogrify png images that were created or modified after a certain date for example yesterday or a few days ago etc? Would you use the identify command, what would the syntax be when added to the above mogrify command? Can you chose either modified or created?



Newbie using the latest Ubuntu.

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-12T23:35:54-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown


Mogrify has no filter for date. So move all the images that conform to your date into a new folder and then use mogrify on that folder.

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-13T04:24:48-07:00
by IMuser1
It's
ImageMagick 6.9.7-4 Q16 x86_64 20170114
with Ubuntu 18.04.

I thought since it was the most recent standard version of Ubuntnu everyone would be using the same one or at least know which one it has.
So there's no way to select only today's images for example?

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-13T07:29:16-07:00
by GeeMack
IMuser1 wrote: 2018-08-13T04:24:48-07:00So there's no way to select only today's images for example?
You'll have to use one of your system utilities like "find" to locate the files that meet your criteria. Redirect the output of the "find" command to a text file to use as your list of files to process. Then you can read that text file into "mogrify" using the "@" flag. I'm not at a *nix machine to test, but this command should work as a simple example...

Code: Select all

find *.png -mtime -1 > list.txt

mogrify -resize 50% @list.txt
That would use "find" to get all the *.png images newer than 1 day and print them to a file named "list.txt". Then "mogrify" reads that list, processes the images, and overwrites the originals with the resized versions. There may be minor differences in the behavior of "find" from one system to another, so you'll have to check the man page for the exact usage.

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-13T07:51:08-07:00
by IMuser1
Great I tested it and it works. Thanks.

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-13T08:52:24-07:00
by fmw42
Your version
ImageMagick 6.9.7-4 Q16 x86_64 20170114
by version is ancient. By patch date, 1/14/2017, it is over a 1 1/2 years old. Check with your Linux distro to see if there is more current patch.

Re: Command to Mogrify png images created or modified after a certain date only?

Posted: 2018-08-13T20:58:29-07:00
by IMuser1
I installed it from synaptic using standard Ubuntu 18.04 updated with latest updates.