Finding Files by Date Modified

I need to be able to find all files in my Documents folder modified within the last weeek. (I need to be able to do this to back it up in Backup, which does not allow users to choose files by date modified.)

How is this done with Automator?


Much thanks!

Mac OS X (10.4.9)

Posted on Jun 13, 2007 11:47 AM

Reply
13 replies

Jun 13, 2007 12:06 PM in response to kurt.grossman

Use a "Run Shell Script" automator action with the following command: find ~/Documents -type f -ctime -7

The "-ctime" looks at change times, and the -7 says to look for changes less than 7 * 24 hours ago. The "-type f" limits it to regular files.

The output of that is a list of file paths that have changed.

You can look at the man page for find in the Terminal for more details and options.

HAL 9000

Jun 13, 2007 12:08 PM in response to kurt.grossman

Activate the Finder. Press COMMAND-F to open the search window. Change the Last Opened button to Last Modified and set the Any Date button to This Week. Click on the Save button to save the search as a Smart Folder. The Smart Folder will automatically reflect all files in the Documents folder that were modified within the last week (you can set your own specific date requirements if you want.)

Backup doesn't allow you to choose files by Date Modified because that is partly how Backup automatically determines what new files require backing up. In fact that's how most backup programs work. If you use an incremental backup only files modified since the last backup are backed up. So in reality there's really no need to do what you propose.

Jun 13, 2007 1:12 PM in response to kurt.grossman

If you want them in a folder, then Kappy's suggestion is probably better.

You can see the result of the shell command by putting the Automator action "View Results" after it. Once you are getting the list you want, you could use that list to drive the operation of Automator actions to do whatever you wanted with those files. This gives a lot of flixibility, but for your purpose, I'd probably do what Kappy said.

Jun 13, 2007 3:16 PM in response to Kappy

Thank you so much for your help. It lead me to a solution!

I tried Smart Folders before, but Backup does not recognize them 😟 .

I am doing a weekly full disk image copy with Carbon Copy Cloner because I can't afford to be without all my stuff! I have an older used Mac on reserve in the event my hard drive (...) should crash. Should I my powerbook ever be out of service or need repair, I have a full backup of my entire disk image ready to go!

However, during the week I need to backup documents that I have been working on inbetween my weekly image copy. Unfortunately, Backup won't let me find and copy these files. Your solution with Automator (and the shell script) work great.

Thanks again!


Best regards,

Kurt Grossman

Jun 14, 2007 6:51 AM in response to Calvados

I ran the script yesterday and it seemed to have worked fine. However, I ran it again this morning to test it, and it only found files changed since the last time I ran the script, rather than all the "7 days". I immediately ran it again, and it returned empty.

I need all changes made to all files within the last 7 days, which seemed to work the first time. ??? I'm I missing something?

Any ideas? 🙂

Thanks again!


Best regards,

Kurt

Jun 14, 2007 6:59 AM in response to kurt.grossman

Are you moving the files out of the directory as a result of your process? Are you running any utilities against the files that might change their modification times?

The "find" command gets the same result on my computer no matter how many times I run it.

I don't know the backup tool you talk about, but Kappy mentioned that it uses modification times, so it might affect them. Perhaps it takes care of modificaton times itself, and all you need to do is to point it at the folder to be backed up.

Jun 14, 2007 8:54 AM in response to Calvados

I am not running any utilities, but here is what I am doing in Automator:

1. Run Shell Script
find /Users/kurtwgrossman/Documents/ -type f -ctime -7

2. View Results
3. Move Finder Items
To: [a folder for the files]

This process will only list [View Results] the files changed since the last time I ran the script, not all files changed from the past 7 days.

Thanks!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Finding Files by Date Modified

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.