Delete a specific file when an app isn't running

Posted:
Tue Oct 20, 2020 2:52 am
by ruiguerreiro
Hello there,
I would like to automate the maintenance cleaning of my Lightroom's photo preview cache file, which can get really big sometimes. Currently, I go to the folder where it is located and delete it, but I often forget to do so and this huge file builds up in my hard drive.
I know how to automate this in Hazel, but I would like the automation to happen only if Lightroom is not running. Is this possible? How can I tell Hazel to do so?
Thank you so much,
Rui
Re: Delete a specific file when an app isn't running

Posted:
Tue Oct 20, 2020 10:12 am
by Mr_Noodle
You'd need a script to be able to tell if Lightroom is running. You might want to search around as there should be an AppleScript out there which can check that.
Re: Delete a specific file when an app isn't running

Posted:
Tue Oct 20, 2020 11:49 am
by ruiguerreiro
Mr_Noodle wrote:You'd need a script to be able to tell if Lightroom is running. You might want to search around as there should be an AppleScript out there which can check that.
Hi there,
Thank you so much. Sadly, although I tried, I wasn’t able to find any post about this type of script. I don’t think that creating a new post will help, so if anyone knows where I can find such a script, I would be grateful.
Thank you so much!
Re: Delete a specific file when an app isn't running

Posted:
Wed Oct 21, 2020 10:43 am
by Mr_Noodle
Try the following:
- Code: Select all
if application "Lightroom" is running then
return true
else
return false
end if
Use this as an embedded AppleScript in a rule condition (not action). I can't really give too much support for scripts but the above should be enough to get you on the right course.
Re: Delete a specific file when an app isn't running

Posted:
Fri Oct 23, 2020 1:35 am
by ruiguerreiro
Mr_Noodle wrote:Try the following:
- Code: Select all
if application "Lightroom" is running then
return true
else
return false
end if
Use this as an embedded AppleScript in a rule condition (not action). I can't really give too much support for scripts but the above should be enough to get you on the right course.
It think that it works! Thank you so much for taking the time.