I’m really struggling with a folder action that I have a feeling is pretty easy to accomplish. I need a folder action that will make an alias file of the added item(s) to the desktop. Thanks.
Figured it out:
on adding folder items to thisFolder after receiving theseItems
set desktopFolder to (path to desktop folder)
tell application "Finder"
repeat with thisItem in theseItems
make new alias file to thisItem at desktopFolder
end repeat
end tell
end adding folder items to
Hi Rob,
you don’t need the repeat loop:
on adding folder items to thisFolder after receiving newItems
tell application "Finder" to make new alias file at desktop to every item of newItems
end adding folder items to
Thanks Dominik. Your script works well but I have been able to cause it to fail by throwing too many files at it. It shouldn’t affect my purposes as I’m using the script for an incoming fax folder where quantity and frequency will be negligible.
Now how would one reverse this Folder Action? For example I want to make a neat bunch of Finder Aliases of new apps that I put into Applications folder. On top of that, when I delete any apps from Applications folder, I want to get those Finder Aliases deleted along so that there won’t be orphaned Finder Aliases.
This is what I came up with as the Alias-generating side of the Applescript for Applications folder action:
-- yay my first Applescript!!
on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder "New Apps to Dock" of this_folder) then
make new folder at this_folder with properties {name:"New Apps to Dock"}
end if
set the destination_folder to folder "New Apps to Dock" of this_folder as alias
set the destination_directory to POSIX path of the destination_folder
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to info for this_item
make new alias file at destination_folder to this_item
end repeat
end tell
end adding folder items to
Although this is much longer than the others above, it works nicely. What would work for the Alias-deleting side?
Maybe using “delete” in Applescript? “rm” in shell script?