Last active
February 13, 2016 19:53
-
-
Save lpar/d1b795dc7a216f307118 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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