[SOLVED] Auto delete confirmation ?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

[SOLVED] Auto delete confirmation ? Fri Jun 15, 2018 5:56 am • by mickaelperrin
Hi,

I try to implement an automatic ask for deletion of files in my download folder that were added more than X days ago.

I tried to implement an apple script to do that, and started with this script:

Code: Select all
display dialog "Delete file " & theFile & " ?" buttons {"No", "Yes"} default button 2 with title "Hazel: Auto clean download folder" with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:FullTrashIcon.icns"


But so far, this doesn't work I get "Error executing apple script on the file" ?

Is it possible to achieve that task with Hazel ? Is the beginning of my applescript wrong ? Are there better ways to do that ?

Thanks,
Last edited by mickaelperrin on Fri Jun 15, 2018 12:54 pm, edited 1 time in total.
mickaelperrin
 
Posts: 3
Joined: Fri Jun 15, 2018 5:43 am

Re: Auto delete confirmation ? Fri Jun 15, 2018 10:48 am • by Mr_Noodle
Try putting that within a block like:
Code: Select all
tell application "System Events"
    ....
end tell


Hazel runs rules in a non-GUI process so you need to tell System Events to display the dialog.
Mr_Noodle
Site Admin
 
Posts: 11250
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Auto delete confirmation ? Fri Jun 15, 2018 12:54 pm • by mickaelperrin
Awesome thanks !
mickaelperrin
 
Posts: 3
Joined: Fri Jun 15, 2018 5:43 am


Return to Support