Automater-filter finder items by date not working

Hi,


Using automator I am trying to filter a list of items in a folder by date modified, and it is selecting files it shouldn't be. I have a folder of daily database backups and I want to create a folder action that will delete any backups older than two months. This I thought would be easy, and my workflow works up to a point.


The workflow is as follows:

1. Get folder contents

2. Filter finder items:

-select all items where date last modified is not in the last 2 months.

3. Move finder items to trash.


The above workflow works if there are no items in the folder with todays date. As soon as the newest backup is added to the folder, triggers the action and any old items, plus this newest backup are moved to the trash. Why is it doing this?


I have tried various different tests to determine if it is remembering the file passed to the action when it drops in to the folder. But if I put an item with todays date in the folder then run the action by dropping an older item on the folder, it still moves the newest item to the trash.


This is bizarre behaviour unless I am missing something. Could it be that it is moving the newest item to the trash because it hasn't yet been indexed by spotlight? If that is the case then automator needs to stop using spotlight as a means of finding items because that is just rubbish.


Does anyone have any ideas?


Thanks.

Mac mini, Mac OS X (10.6.8)

Posted on Sep 3, 2011 2:38 PM

Reply
4 replies

Sep 3, 2011 9:08 PM in response to Nicola Hastings

I tested this for a bit, but still don't know what they did that includes the new(er) item - probably some kind of overflow issue. I've pretty much given up on Automator because of continual quirks like this - you will probably have better luck using an AppleScript or a shell script, for example using the find utility.


Note that a folder action will fire each time something is added, so it is not a good idea to do stuff like create an archive in the attached folder, since that will trigger the action again. The specific items that were added are also passed to the workflow, so you don't really need to get additional items or use the entire contents of the folder.

Sep 4, 2011 3:03 AM in response to red_menace

Thanks for your reply, that's what I thought.


It's a great shame that there's so many problems with automator. I just discovered it recently and thought what a great little app to make it easier to do the things I thought I'd have to do with applescript. How wrong I was as there's been nothing but problems with it and I've only been able to get it to automate one task successfully. (And that was in Leopard.)


I guess I'll have to go and learn applescript afterall.


😟

Sep 4, 2011 8:38 AM in response to Nicola Hastings

I have a Filter Finder Items by Age Automator action on my iDisk that you can try - it has been a while since I checked it, but it should be more or less quirk-free in Snow Leopard - Lion is another story. It is an AppleScript-based action that uses Spotlight (Xcode source files are included), although you should probably rethink your workflow - possibly something like:


Folder Action receives files and folders added to choose your drop folder

1) Set Value of Variable { Variable: Original Items } -- save for later

2) Create Archive { Where: your archive folder } -- archive to a different folder

3) Get Specified Finder Items { drag your archive folder here } (Ignore Input)

4) Get Folder Contents -- get items in your archive folder

4) Filter Finder Items by Age { Return items whose modified date is older than 2 months }

5) Move Finder Items to Trash

6) Get Value of Variable { Variable: Original Items } (Ignore Input) -- get originals back

7) Move Finder Items { To: wherever } -- or whatever else

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.

Automater-filter finder items by date not working

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