Applescript Dialog Box not going away after Big Sur

Joined
Nov 23, 2020
Messages
1
Reaction score
0
I have a Folder Action Script that I cobbled together while back that monitors when a USB drive is attached, then looks for a shell script on that drive and runs it if I tell the Folder Action Script "Yes". If I click "No" it closes out the dialog and all is well.

It still works at the heart of things, however now when I click "Yes" the dialog box stays visible until the shell script completes, whereas in the past it would disappear immediately after clicking "yes" or "No".

Any help is greatly appreciated, and thanks in advance!

Code:

property dialog_timeout : 60

on adding folder items to this_folder after receiving added_items
set shFiles to {}
repeat with current_item in added_items
try
set end of shFiles to ((current_item as text) & ".Autosync.sh") as alias -- check if ".Autosync.sh" exists
end try
end repeat
if shFiles is not {} then
tell application "Finder" to set the folder_name to the name of this_folder
-- find out how many .Autosync.sh
set the item_count to count shFiles
--create the alert string
set alert_message to ("External Drive Attached" & 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 drives have "
else
set alert_message to alert_message & "One new drive has "
end if
set alert_message to alert_message & "been attached, in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
set the alert_message to (the alert_message & return & return & "Would you like to run Autosync?")
activate
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
repeat with shFile in shFiles
try
do shell script quoted form of POSIX path of shFile
end try
end repeat
end if
end if
end adding folder items to
 

Cory Cooper

Moderator
Joined
May 19, 2004
Messages
11,105
Reaction score
497
Hello and welcome.

I am not very experienced with scripting. Sounds like there may have been some change in Big Sur that is affecting it. Maybe another member here with more experience will chime in, or you could try the folks over at MacScripter.

C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top