Skip to content

Instantly share code, notes, and snippets.

@lpar
Last active February 13, 2016 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpar/d1b795dc7a216f307118 to your computer and use it in GitHub Desktop.
Save lpar/d1b795dc7a216f307118 to your computer and use it in GitHub Desktop.
-- This is the script piece of an Automator workflow, it won't work without the rest of the workflow.
on run {input, parameters}
set maxDaysOld to 14 -- This is the number of days of stuff to keep
set oldFiles to {}
set oldFilesRef to a reference to oldFiles
repeat with n from 1 to length of input
set thing to item n of input
set dateAddedString to (do shell script "mdls -name kMDItemDateAdded -raw " & quoted form of POSIX path of thing)
set dateadded to the (date dateAddedString)
set daysold to ((current date) - dateadded) / 86400
if daysold > maxDaysOld then
copy (item n of input) to the end of oldFilesRef
end if
end repeat
return oldFiles
end run
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment