Tell if application is running before deleting a file

Lightroom 4 has a cache file called Previews.lrdata that keeps growing and growing.
I would like to set up a Hazel rule to delete this file periodically. The problem is I can't delete the file if Lightroom (LR) is running or, since this is a cache file, deleting it while LR is running will crash LR.
I found the following code snippet function, but I'm not sure how I would integrate this into a rule inside Hazel.
Hazel seems to wants to have "Passes AppleScript" as the condition so I somehow need to negate the passing when LR is running and return "false" to the rule. IOW, I don't want to delete the file if LR is running.
display dialog appIsRunning("Adobe Photoshop Lightroom 4")
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
(This does seems to work when run from the AppleScript editor.)
----
Would appreciate any suggestions.
Thanks in advance,
-- m
I would like to set up a Hazel rule to delete this file periodically. The problem is I can't delete the file if Lightroom (LR) is running or, since this is a cache file, deleting it while LR is running will crash LR.
I found the following code snippet function, but I'm not sure how I would integrate this into a rule inside Hazel.
Hazel seems to wants to have "Passes AppleScript" as the condition so I somehow need to negate the passing when LR is running and return "false" to the rule. IOW, I don't want to delete the file if LR is running.
display dialog appIsRunning("Adobe Photoshop Lightroom 4")
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
(This does seems to work when run from the AppleScript editor.)
----
Would appreciate any suggestions.
Thanks in advance,
-- m