The Finder in Mac OS X 10.7 Lion shows a new piece of file metadata, "Date Added," which tracks the date an item was added to a folder. After upgrading to 10.7, none of the items in my ~/Downloads
folder have "Date Added" values. I'd like to set all the empty "Date Added" values to match the "Date Modified" values, but I can't figure out how to set the "Date Added" attribute to a specific value.
My first guess was this:
xattr -w com.apple.metadata:kMDItemDateAdded "2012-02-19 16:34:47 +0000" myfile
But that doesn't seem to work (though it doesn't report an error either).
Best Answer
OK, new approach here. Caution: I don't have a system upgraded to Lion (my computer came with Lion installed) so I can't test this. Untested code; back up before trying this code!
My previous answer was based on the sort order used by the Downloads stack in the Dock. The Date Added field in the Finder appears to be based on Spotlight information, which is difficult to hack. It also isn't accessible via AppleScript. But, there does seem to be a workaround.
Create a new Workflow in Automator.
Set the workflow to accept files or folders from the Finder by adding the “Ask for Finder items” action.
Have the workflow run an AppleScript by adding the “Run AppleScript” action.
Use this AppleScript:
Select the files that do not already have a Date Added (sort by Date Added in Finder, then select the part of the list without a Date Added) and run this service.