(* AutoStacks 0.2 by Mike Fahy, nospam@turdhead.com Copyright (C) 2007 by Mike Fahy Released under the common THC (TurdHead.Com) license, which doesn't actually exist. AutoStacks gives some of the functionality many of us expected to see in the final implementation of OS X Leopard "Stacks" -- Drag any random assortment of files onto this app, and a new Stack is generated containing only those files. Behind the scenes, this script will create an "AutoStacks" folder in your home directory and place other directories to represent each new stack. Just as with any other stack, removing the stack from your Dock will not remove this directory or its contents. Note 1: USE AT YOUR OWN RISK! To add this functionality, AutoStacks writes to your default Dock.plist file, and in theory could ruin it. It hasn't wrecked mine, however, but I do not in any way guarantee it won't destroy you, your computer and everything you hold dear to your heart. Thus, USE AT YOUR OWN RISK. I am not, nor have I ever been, responsible for anything you or your computer might do. Note 2: Turdhead.com is not that bad of a domain name. Really. Enjoy! *) property defaultBehavior : "None" on run display dialog "AutoStacks will create a new stack made up of the files and folders dragged onto its icon. Based on your choice here, AutoStacks will either move selected files and folders to the new Stack directory, or simply create aliases to the existing files within a new stack (In this case, the files will not actually be moved). Please choose which behavior you would like to enable by default. You may change this behavior at any time by launching AutoStacks without dragging files to its icon." buttons {"Move files", "Create aliases"} default button "Move files" set behavior to the button returned of the result if behavior is "Move files" then display dialog "You have chosen to move dragged files into a new directory within the current user's AutoStacks directory. This will now be the default behavior for AutoStacks." set defaultBehavior to "Move" else if behavior is "Create aliases" then display dialog "You have chosen to create aliases to dragged files within newly created AutoStacks directories. The original files will remain in their current locations. This will now be the default behavior for AutoStacks." set defaultBehavior to "Alias" end if end run on open files_ if defaultBehavior is "None" then run end if set stackDir to "AutoStacks" as string set plistStart to "tile-datahome directory relative" set plistEnd to "arrangement2showas1tile-typedirectory-tile" set timeStr to time string of (current date) set cPosition to offset of ":" in timeStr set theHour to characters 1 thru (cPosition - 1) of timeStr as string set timeStr to characters (cPosition + 1) through end of timeStr as string set cPosition to offset of ":" in timeStr set theMin to characters 1 thru (cPosition - 1) of timeStr as string set timeStr to characters (cPosition + 1) through end of timeStr as string set cPosition to offset of ":" in timeStr set theSec to characters 1 thru (cPosition - 1) of timeStr as string set timeStr to year of (current date) & (month of (current date) as integer) & day of (current date) & timeStr as string set timeStrTmp to timeStr set timeStr to "" repeat while timeStr is "" display dialog "Please provide a label for the new Stack:" default answer timeStrTmp set timeStr to text returned of result end repeat set myPath to (path to home folder) as string tell application "Finder" launch -- Make the AutoStacks folder if it's not there already try make new folder at myPath with properties {name:"AutoStacks"} end try set stackFolder to myPath & stackDir as string try make new folder at stackFolder with properties {name:timeStr} end try set newStackFolder to stackFolder & ":" & timeStr set iPath to path to me as string set iconFile to iPath & "Contents:Resources: IconOverlay" copy folder iconFile to " " in folder newStackFolder repeat with file_ in files_ if defaultBehavior is "Move" then move file_ to newStackFolder else make alias to file_ at newStackFolder end if end repeat do shell script "defaults write com.apple.dock persistent-others -array-add '" & plistStart & POSIX path of newStackFolder & plistEnd & "'" do shell script "killall -HUP Dock" -- This will set the Modification Date of the IconOverlay file so it remains on top of the Stack do shell script "touch -mt 202001010101.01 \"" & POSIX path of iconFile & "\"" activate end tell end open