0
votes

I have tweaked the 'add - new item alert' apple script and applied it as a folder action to my 'Volumes' folder. The tweaked script is suppose to detect when a new USB drive is inserted and open an app (Automator workflow), which then copies a file to the drive and ejects it.

Issue 1

When I run the script within AppleScript Editor it works. However, when the script runs automatically when a USB drive is inserted it only tells me that it has detected the new drive and does not open the app. I am using do shell script "open -a Conference_Copy_Paste" to open the app which is located within my applications folder (see the AppleScript code below).

Start of code Used --->

property dialog_timeout : 0 -- set the amount of time before dialogs auto-answer.

do shell script "open -a Conference_Copy_Paste"

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?")

    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

<--- End of code Used

Issue 2

After using this app for about 10 times I begin to get an error while running it. The error reads "You don't have permission to save the file "whatever file" in the folder "whatever folder"." The only way to resolve this issue is restarting my system. Is there a better way to solve this particular issue?

Automator app's workflow runs 'Get Specified Finder Items', 'Copy Finder Items' and then 'Eject Disk'.

Thanks in advance to anyone who could help me solve this. I desperately need this to work as I have to copy and paste files to 1k USB drives for a conference.

1

1 Answers

0
votes

Try moving

do shell script "open -a Conference_Copy_Paste"

to within:

on adding folder items to this_folder after receiving added_items