Page 1 of 1

[SOLVED] Auto delete confirmation ?

PostPosted: 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,

Re: Auto delete confirmation ?

PostPosted: 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.

Re: Auto delete confirmation ?

PostPosted: Fri Jun 15, 2018 12:54 pm
by mickaelperrin
Awesome thanks !