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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
IMuser1
Posts: 4
Joined: 2018-08-12T22:50:46-07:00
Authentication code: 1152

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
IMuser1
Posts: 4
Joined: 2018-08-12T22:50:46-07:00
Authentication code: 1152

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

Post 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?
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
IMuser1
Posts: 4
Joined: 2018-08-12T22:50:46-07:00
Authentication code: 1152

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

Post by IMuser1 »

Great I tested it and it works. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
IMuser1
Posts: 4
Joined: 2018-08-12T22:50:46-07:00
Authentication code: 1152

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

Post by IMuser1 »

I installed it from synaptic using standard Ubuntu 18.04 updated with latest updates.
Post Reply