Page 1 of 1
Running batch file only on images recently modified
Posted: 2018-10-13T23:24:42-07:00
by harryhermit
Hi,
I run a batch script to modify images in folders and subfolders in windows. It works great, but it runs imagemagick for every single image in the folders. Is there a way to limit the files that are modified to a time period eg. a week from date modified?
Thanks
Re: Running batch file only on images recently modified
Posted: 2018-10-14T02:30:54-07:00
by Bonzo
I would suggest you create a script to loop through all the files you want to modify and only send the one to IM that meet the criterial.
Just remember if you go by time span you will have to make sure the ones you ran in the previous run are older; otherwise they will be changed again.
Re: Running batch file only on images recently modified
Posted: 2018-10-14T10:40:14-07:00
by fmw42
You would have to use your OS to test the modified date in your loop and do an if test on the date range. If it passes then process. If it does not pass, then skip the file via you looping mechanism (such as continue in unix)
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Re: Running batch file only on images recently modified
Posted: 2018-10-14T14:52:51-07:00
by GeeMack
harryhermit wrote: ↑2018-10-13T23:24:42-07:00I run a batch script to modify images in folders and subfolders in windows. It works great, but it runs imagemagick for every single image in the folders. Is there a way to limit the files that are modified to a time period eg. a week from date modified?
As the others have mentioned, you'll probably do best to use some system utility to check or sort your files according to the modified times/dates. If you're using Windows Vista or newer, try this at the command line to learn about the "forfiles" command...
That can find files that meet certain criteria, then it can echo those files' names to a list for IM to use, or it can run an IM command on each qualifying file.
Re: Running batch file only on images recently modified
Posted: 2018-10-15T00:04:34-07:00
by harryhermit
The forfiles command looks promising, but I'm having issues with it bringing up the correct products with my criteria. What's the correct command to bring products that have been modified within the past 7 days? I tried this command, but it seems to bring products that are older than 7 days ago:
forfiles /D -7
Using
forfiles /D +7 doesn't bring up any results
I can get the last 7 days by setting the command to bring files newer than a date 7 days from the current date, but I'd have to manually set the date each time. That wouldn't be the automatic solution I am seeking
forfiles /D +10/08/18
Any help would be appreciated