ok, i’m making a program that prompts you to choose a file until you hit the cancel button in the choosefile prompt. When you hit cancel I want a prompt to come up asking if you want to empty the trash.
heres my code right now:
property file_name : path to desktop folder
property outputPath : path to trash
property inputName : "Desktop"
property outputName : "Trash"
property dialogPrompt : "Choose the file that you want to delete. Press cancel when your done deleting files. "
property confirmButton : "Move to " & outputName
property cancelButton : "Don't Move to " & outputName
property dialogButtons : {cancelButton, confirmButton}
repeat until (file_name is false)
tell application "Finder"
set file_name to (choose file with prompt dialogPrompt)
display dialog ("Are you sure you want to delete" & file_name & "?") buttons dialogButtons default button confirmButton
if button returned of result is confirmButton then
move file ((file_name as string)) to outputPath
if file_name is false then
display dialog "Would you like to empty the trash now?" buttons {"Yes", "No"} default button "Yes"
set trash_choice to button returned of result
if trash_choice is "Yes" then
tell application "Finder"
empty trash
end tell
else if trash_choice is "No" then
error number -128 --cancel
end if
end if
end if
end tell
end repeat