Delete a specific file when an app isn't running

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

Moderator: Mr_Noodle

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
ruiguerreiro
 
Posts: 11
Joined: Thu Oct 17, 2019 10:35 am

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.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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!
ruiguerreiro
 
Posts: 11
Joined: Thu Oct 17, 2019 10:35 am

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.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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.
ruiguerreiro
 
Posts: 11
Joined: Thu Oct 17, 2019 10:35 am


Return to Support