Folder Actions
Folder Actions are AppleScripts that can be set to be triggered when a folder opens.
Contents:
Move Snapshots into a subfolder and rename them.
Window Resizing
Document Locking
Popup Windows

My old Marathon playing buddy, Gabriel Sterritt, wrote a very cool Applescript Folder Action. I have it attached to my hard disk icon and now when I open my disk, any snapshots laying around are moved into their own folder. Additionally, they are renamed with a "Timecode Stamp". If you snap a lot of screen captures, download the script and give it a spin.
When I open my hard disk, I like the window to be in the upper left corner and resized to show the main 9 icons.
After hitting the Record button in the Script Editor, I opened the hard disk, moved the folder, and resized it. This is what the was the script looked like:
tell application "Finder"
activate
select startup disk
open selection
set position of container window of startup disk to {10, 45}
set size of container window of startup disk to {215, 195}
end tell
To turn it into a Folder Action, it needs a couple of more lines:
on opening folder startup disk
tell application "Finder"
activate
select startup disk
open selection
set position of container window of startup disk to {10, 45}
set size of container window of startup disk to {215, 195}
end tell
end opening folder
After saving the script with the Compiled option, I attached it to my hard disk using the Folder Action contextual menu. Now when I open the drive, the window snaps to the corner, and is just the right size, regardless of of where I last left it!

John Dwight uses this simple AppleScript Folder Action to protect any documents he places in the folder. The script contains a simple error catching routine:
on adding folder items to parent_folder after receiving added_items
try
tell application "Finder"
set locked of files of parent_folder to true
end tell
on error x
tell application "Finder"
display dialog x
end tell
end try
end adding folder items to
-- Due to current Folder Actions implementation
-- the script runs only when Dragging-and-Dropping files into the open scripted folder.
-- I haven't yet found a way to lock newly added files to a parent folder from the Save diaolg.
-- Use at your own risk and enjoy. John Dwight dwight@ic.si.edu
n8 Alf created this folder action AppleScript. Attach it to a folder, and everytime someone opens moves the folder, it becomes a popup window.
on opening folder ThisFolder
my SetPopUp(ThisFolder)
end opening folder
on moving folder window for ThisFolder
my SetPopUp(ThisFolder)
end moving folder window for
on SetPopUp(ThisFolder)
tell application "Finder"
if popup of window of folder ThisFolder is false then
activate
-- in the following line you can determnine the window view
-- choices are: icon, small icon, name
set view of window of folder ThisFolder to name
set spatial view arrangement of window of folder ThisFolder to arranged by name
set zoomed of window of folder ThisFolder to true
set popup of window of folder ThisFolder to true
set pulled open of window of folder ThisFolder to false
end if
end tell
end SetPopUp

Back to the Archive