Created
March 5, 2010 21:34
-
-
Save sirlancelot/323181 to your computer and use it in GitHub Desktop.
This is a launchd script that will watch my "Downloads" folder and automatically trash files that are over 14 days old. A log of the trashed files is kept in the Console Messages. NOTE: Files are moved to the trash and can be recovered from there.
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
1. Edit the `EnvironmentVariables` and `WatchPaths` to point to your profile. (NOTE: unless you change | |
the `ProgramArguments`, you MUST keep the "Downloads" folder the same. | |
2. Move the file in to your `~/Library/LaunchAgents` folder. | |
3. Log out and back in. | |
If you want, open up Console.app and watch "Console Messages" for files that were trashed. an example | |
message looks like: | |
3/5/10 1:30:43 PM me.mpietz.Trash-Old-Downloads[9828] /Users/mpietz/Downloads/test -> /Users/mpietz/.Trash/test |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>me.mpietz.Trash-Old-Downloads</string> | |
<key>EnvironmentVariables</key> | |
<dict> | |
<key>HOME</key> | |
<string>/Users/mpietz</string> | |
</dict> | |
<key>WatchPaths</key> | |
<array> | |
<string>/Users/mpietz/Downloads</string> | |
</array> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/bin/sh</string> | |
<string>-c</string> | |
<string>/usr/bin/find $HOME/Downloads -mtime +14 -exec mv -v '{}' $HOME/.Trash \;</string> | |
</array> | |
<key>KeepAlive</key> | |
<false/> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment