I have a folder action script that will file anything I put on the desktop, then create an alias there. Unfortunately, it doesn’t work.
global theItem
on adding folder items to thisFolder after receiving addedItems
repeat with theItem in addedItems
tell application "Finder" to set theKind to the kind of theItem
if theKind contains "Image" then
my iLifeAdd("iPhoto")
else if theKind contains "Movie" or "Video" then
my iLifeAdd("iTunes Video")
else if theKind contains "Audio" then
my iLifeAdd("iTunes Audio")
else if theKind contains "Application" then
my moveTo("Macintosh HD:Users:willie:Applications:New Apps:")
else if theKind contains "Document" or "Text" then
my moveTo("Macintosh HD:Users:willie:Documents:The Junk Drawer:Swept:")
else if theKind does not contain "Folder" or "Alias" then
set unknownAction to button returned of (display dialog "There is an unknown item on your desktop. What do you want to do with it?" buttons {"Add to Script", "Choose Folder", "Default Destination"} default button 3)
if unknownAction is "Add to Script" then
tell application "Script Editor" to open (path to me as text)
else if unknownAction is "Choose folder" then
set moveFolder to (choose folder)
my moveTo(moveFolder)
else if unknownAction is "Default Destination" then
my moveTo("Macintosh HD:Users:willie:Desktop:Dustpan:")
end if
end if
end repeat
end adding folder items to
on iLifeAdd(iLifeApp)
set iLifeOrNot to button returned of (display dialog "Do you want to add this to iLife or the User folder?" buttons {"iLife", "Folder"})
if iLifeOrNot is "iLife" then
if iLifeApp contains "iTunes" then
tell application "iTunes"
add theItem
end tell
else if iLifeApp is "iPhoto" then
tell application "iPhoto"
add theItem
end tell
end if
else if iLifeOrNot is "Folder" then
if iLifeApp contains "Audio" then
my moveTo("Macintosh HD:Users:willie:Music:Swept:")
else if iLifeApp contains "Video" then
my moveTo("Macintosh HD:Users:willie:Movies:Swept:")
else if iLifeApp contains "iPhoto" then
my moveTo("Macintosh HD:Users:willie:Photos:Swept:")
end if
end if
end iLifeAdd
on moveTo(destination)
tell application "Finder"
move theItem to destination
make alias to theItem at desktop
end tell
end moveTo
Great, that simple line fixed it! Unfortunately, half the time it won’t recognize the file format. All I changed was adding the line you suggested and adding “Word” to the document format. Here’s the script again:
global theItem
on adding folder items to thisFolder after receiving addedItems
repeat with oneItem in addedItems
set theItem to contents of oneItem
tell application "Finder" to set theKind to the kind of theItem
if theKind contains "Image" then
my iLifeAdd("iPhoto")
else if theKind contains "Movie" or "Video" then
my iLifeAdd("iTunes Video")
else if theKind contains "Audio" then
my iLifeAdd("iTunes Audio")
else if theKind contains "Application" then
my moveTo("Macintosh HD:Users:willie:Applications:New Apps:")
else if theKind contains "Document" or "Text" or "Word" then
my moveTo("Macintosh HD:Users:willie:Documents:The Junk Drawer:Swept:")
else if theKind does not contain "Folder" or "Alias" then
set unknownAction to button returned of (display dialog "There is an unknown item on your desktop. What do you want to do with it?" buttons {"Add to Script", "Choose Folder", "Default Destination"} default button 3)
if unknownAction is "Add to Script" then
tell application "Script Editor" to open (path to me as text)
else if unknownAction is "Choose folder" then
set moveFolder to (choose folder)
my moveTo(moveFolder)
else if unknownAction is "Default Destination" then
my moveTo("Macintosh HD:Users:willie:Desktop:Dustpan:")
end if
end if
end repeat
end adding folder items to
on iLifeAdd(iLifeApp)
set iLifeOrNot to button returned of (display dialog "Do you want to add this to iLife or the User folder?" buttons {"iLife", "Folder"})
if iLifeOrNot is "iLife" then
if iLifeApp contains "iTunes" then
tell application "iTunes"
add theItem
end tell
else if iLifeApp is "iPhoto" then
tell application "iPhoto"
add theItem
end tell
end if
else if iLifeOrNot is "Folder" then
if iLifeApp contains "Audio" then
my moveTo("Macintosh HD:Users:willie:Music:Swept:")
else if iLifeApp contains "Video" then
my moveTo("Macintosh HD:Users:willie:Movies:Swept:")
else if iLifeApp contains "iPhoto" then
my moveTo("Macintosh HD:Users:willie:Photos:Swept:")
end if
end if
end iLifeAdd
on moveTo(destination)
tell application "Finder"
move theItem to destination
make alias to theItem at desktop
end tell
end moveTo
Ok, I have a wierd problem. Every time I open this script, iPhoto opens. Any ideas on why and how to avoid it?
Here’s my updated script, if that makes any difference:
global theItem
on adding folder items to thisFolder after receiving addedItems
repeat with oneItem in addedItems
set theItem to contents of oneItem
tell application "Finder" to set theKind to the kind of theItem
if theKind contains "Pixelmator" then
set theKind to "Image"
else if theKind contains "Disk Image" then
set theKind to "Ignore"
end if
if theKind contains "Image" then
my iLifeAdd("iPhoto")
else if theKind contains "Movie" or theKind contains "Video" then
my iLifeAdd("iTunes Video")
else if theKind contains "Audio" then
my iLifeAdd("iTunes Audio")
else if theKind contains "Application" then
my moveTo("Macintosh HD:Users:willie:Applications:New Apps:")
else if theKind contains "Document" or theKind contains "Text" or theKind contains "Word" then
my moveTo("Macintosh HD:Users:willie:Documents:The Junk Drawer:Swept:")
else if theKind does not contain "Folder" or theKind does not contain "Alias" or theKind does not contain "Ignore" then
set unknownAction to button returned of (display dialog "There is an unknown item on your desktop. What do you want to do with it?" buttons {"Add to Script", "Choose Folder", "Default Destination"} default button 3)
if unknownAction is "Add to Script" then
tell application "Script Editor" to open (path to me as text)
else if unknownAction is "Choose folder" then
set moveFolder to (choose folder)
my moveTo(moveFolder)
else if unknownAction is "Default Destination" then
my moveTo("Macintosh HD:Users:willie:Desktop:Dustpan:")
end if
end if
end repeat
end adding folder items to
on iLifeAdd(iLifeApp)
set iLifeOrNot to button returned of (display dialog "Do you want to add this to iLife or the User folder?" buttons {"iLife", "Folder"})
if iLifeOrNot is "iLife" then
if iLifeApp contains "iTunes" then
tell application "iTunes"
add theItem
end tell
else if iLifeApp is "iPhoto" then
tell application "iPhoto"
add theItem
end tell
end if
else if iLifeOrNot is "Folder" then
if iLifeApp contains "Audio" then
my moveTo("Macintosh HD:Users:willie:Music:Swept:")
else if iLifeApp contains "Video" then
my moveTo("Macintosh HD:Users:willie:Movies:Swept:")
else if iLifeApp contains "iPhoto" then
my moveTo("Macintosh HD:Users:willie:Photos:Swept:")
end if
end if
end iLifeAdd
on moveTo(destination)
tell application "Finder"
move theItem to destination
make alias to theItem at desktop
end tell
end moveTo
Also, it doesn’t seem to be moving anything to the Dustpan folder on my desktop. It asks me where I want to put it, but doesn’t put it there.