Move files if older than x minutes

Started by johnicepick, August 22, 2024, 01:23:34 PM

Previous topic - Next topic

johnicepick

Hello everyone,

I googled this question with different variations, but I did not find the answer I'm looking for.


I'd like to move files into another folder when they are older than x minutes. Preferably based on "Last Modified" and not "DateCreated".
So whenever a photo/file has "Last Modified" timestamp which is older than 3 minutes I want to move it into a different folder.

The code would run as a batch file every few seconds.

I did look into the docs, but I did not find any similar yet?
(For google and for others who may search for the same issue: "Move files if older than x days" "Move files to subfolder if older than x hours" "Copy files if older than x years")

By the way: Thank you for this awesome forum, the time the community invests in answering each of those questions.... true heroes!

StarGeek

The first step is to figure out what the "Last Modified" and "DateCreated" tags actually are.  This would be FAQ #3.

I'm going to assume that "Last Modified" is going to be the FileModifyDate.

Try this
exiftool -if "$FileModifyDate# ge ${Now#;ShiftTime('-0:3:0')}" -Directory=/dir/to/move/to/ /path/to/files/
"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

johnicepick

Hello StarGeek,
Hello everyone,

Thank you very much for your answer.
You're correct with FileModifyDate - that's what I need.

I did notice that your code is not directly working. But instead of whining I searched for a solution. Your ge (greater?) needs to be a le (lesser?) instead, thanks to google & your forum I could figure that one out. I thought at first that the timezones might be in the way, or that the time connotation is missing the day...
Interesting feature: an unaltered JPG created by a photocamera gets directly moved and a edited JPG (Lightroom) will never get moved with the code from above  ???


So exchanging ge with le works like a charm.


So the full line looks like:
exiftool -if "$FileModifyDate# le ${Now#;ShiftTime('-0:3:0')}" -Directory=/dir/to/move/to/ /path/to/files/

This might of interest for other ppl finding my post:
The code above will not move a file if the target directory has a file with an identical name. The following code will rename the file (by adding +1,2,3... at the end of the file).
exiftool -if "$FileModifyDate# le ${Now#;ShiftTime('-0:3:0')}" -filename=C:\targetdirectory\subfolder\%%f%%c.%%e C:\originalfolder\subfolder

Thank you very much StarGeek :)

StarGeek

Ooops, sorry. I misread it and thought you meant more recent than 3 minutes. Glad you figured it out.
"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