I’m trying to write a script or automator action to save as a folder action. I want it to monitor a folder for new items and then make an alais in another folder for the new item.
I have some time right now, post what you have so far and I’ll see if I can help.
I’m still new to this I was going to try modding this sample code
(*
ADD - NEW ITEM ALERT
©2002 Apple Computer
This Folder Action script is designed for use with Mac OS X version 10.2 and higher.
This Folder Action handler is triggered whenever items are added to the attached folder. The script will display an alert
containing the number of items added and offering the user the option to reveal the added items in Finder.
*)
property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer.
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
--get the name of the folder
set the folder_name to the name of this_folder
end tell
-- find out how many new items have been placed in the folder
set the item_count to the number of items in the added_items
--create the alert string
set alert_message to ("Folder Actions Alert:" & return & return) as Unicode text
if the item_count is greater than 1 then
set alert_message to alert_message & (the item_count as text) & " new items have "
else
set alert_message to alert_message & "One new item has "
end if
set alert_message to alert_message & "been placed in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
set the alert_message to (the alert_message & return & return & "Would you like to view the added items?")
display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 1 giving up after dialog_timeout
set the user_choice to the button returned of the result
if user_choice is "Yes" then
tell application "Finder"
--go to the desktop
activate
--open the folder
open this_folder
--select the items
reveal the added_items
end tell
end if
end try
end adding folder items to
I need to cut out the alert part and then make the alais part.
This is how it’s done macrosser: (for my tests, I created two folders on my desktop: one called “dropper” and the other called “AliasFolder”). You can name the dropper anything, and can change the name and location of the alias folder too.
on adding folder items to theFolder after receiving theItems
try
tell application "Finder"
set savedAliases to alias ((path to desktop folder as text) & "AliasFolder:")
repeat with anItem in theItems
make new alias at savedAliases to anItem
end repeat
end tell
on error E
display dialog E
end try
end adding folder items to
without any fail safes…
on adding folder items to thisFolder after receiving theItems
set alias_dest to ((path to desktop) & "Destination Folder") as text
tell application "Finder"
repeat with anItem in theItems
make new alias to file anItem at folder alias_dest
end repeat
end tell
end adding folder items to
Edit
Grrr - Adam beat me to it
It should be possible to distil this kind of routine, without the need to explicitly check names (duplicate names are normally extended/modified automatically), to something like:
property alias_folder : alias "path:to:target:folder:for: aliases" (* modify alias folder as required *)
on adding folder items to after receiving these_items
tell application "Finder" to make alias to these_items at alias_folder
end adding folder items to