Automatically clean-up your desktop
6 March 2013, 09:00
Is your desktop cluttered? What you need is a desktop cleaning app that’ll sort everything away for you — the equivalent of Mary Poppins magically putting everything into the correct drawer!
Here’s how to quickly and easily create a desktop clean-up app that you can use over and over again. It works by creating six new folders on your desktop into which are copied any pictures, music files, documents etc that might be on your desktop.
1. Open AppleScript Editor. You’ll find it in the Utilities folder of the Applications list of Finder.
2. Start a new file if one doesn’t automatically appear (Command+N), then paste in all of the following code:
tell application "Finder" do shell script "mkdir -p ~/Desktop/Music && mkdir -p ~/Desktop/Programs && mkdir -p ~/Desktop/Pics && mkdir -p ~/Desktop/Torrents && mkdir -p ~/Desktop/Video && mkdir -p ~/Desktop/Documents" set myDesktop to alias ((path to desktop folder as text)) -- folders to sort into set myMusic to alias ((path to desktop folder as text) & "Music") set myPrograms to alias ((path to desktop folder as text) & "Programs") set myPics to alias ((path to desktop folder as text) & "Pics") set myTorrents to alias ((path to desktop folder as text) & "Torrents") set myVideos to alias ((path to desktop folder as text) & "Video") set myDocs to alias ((path to desktop folder as text) & "Documents") --extension lists set musicExt to {".mp3", ".aac"} set programsExt to {".dmg", ".sit", ".app"} set picsExt to {".jpg", ".gif", ".tif", ".png", ".psd"} set torrentsExt to {".torrent"} set videosExt to {".avi", ".mpg", ".mov"} set docsExt to {".pdf", ".txt", ".doc", ".xls", ".sav", ".key", ".pages", ".jmp", ".textClipping", ".rtf"} set allFiles to files of myDesktop repeat with theFile in allFiles copy name of theFile as string to fileName repeat with ext in musicExt if fileName ends with ext then move theFile to myMusic end if end repeat repeat with ext in programsExt if fileName ends with ext then move theFile to myPrograms end if end repeat repeat with ext in picsExt if fileName ends with ext then move theFile to myPics end if end repeat repeat with ext in torrentsExt if fileName ends with ext then move theFile to myTorrents end if end repeat repeat with ext in docsExt if fileName ends with ext then move theFile to myDocs end if end repeat repeat with ext in videosExt if fileName ends with ext then move theFile to myVideos end if end repeat end repeat end tell
3. Click the Compile button on the toolbar to make sure the code is OK. If it is, the code will be indented and colorised. If there’s an error you’ll be told.
3. Click File → Save, then give your new app a name and save it somewhere useful (such as in the Applications folder). Before saving, select Application in the File Format drop down list in the Save dialog box.
4. Close AppleScript Editor.
Your new app is ready for use. Whenever you want to clean-up your desktop, just double-click it. There won’t be any progress display apart from the fact that the new folders appear (if they didn’t already exist) and files disappear from your desktop as they’re copied into them. The app will show an icon in the Dock for as long as its running, which in all likelihood won’t be more than a few seconds.
This script is a modified version of an older script found here.
Know better?

◀︎ Create multiple 'inspectors'
Help Mac Kung Fu find readers! ▶︎