How to create a smart folder for files created in the last 5 minutes
I have a camera setup were the camera automatically takes pictures every x seconds and these images are saved in a directory called 'Images'. Now I want to create a smart folder that looks in 'Images' and only lists images that were added in the last 5 minutes. When creating a smart folder, I see only the option the list files from the last day.
How can I create a smart folder that lists only files created in the last 5 minutes?
In other words, I want to create a smart folder using non-standard options.
Solution 1:
A 'Smart folder' is in principle a XML formatted file that, when opened, returns a Spotlight search result. To create a Smart folder you can add multiple search terms by pressing the +
(or alt+
). For example, you can choose to only return files that where created in the last 7 days. Although there is a profusion of search terms, some are still missing (like searching within the last 5 minutes).
The commandline version of Spotlight is mdfind
(manual). Although harder to use, mdfind
commands are more flexable than the Smart folder/Spotlight alternative. You can, for example, search for files that were created in the last 5 minutes like this:
mdfind 'kMDItemFSCreationDate > "$time.now(-300)"'
Or were changed in the last 10 minutes:
mdfind 'kMDItemFSContentChangeDate > "$time.now(-600)"'
Fortunatly Smart folders support the mdfind
command! To use mdfind
search commands do the following:
- Go to Finder and press CommandF to start a new Smart folder.
In the search-items bar you can select 'Other...' from the drop down menu. Search for 'Raw query' and add it to your search terms
-
Now enter your
mdfind
search query in the empty text fieldkMDItemFSCreationDate > $time.now(-600)
Save your search and you are done.