The script looks for .rar files in a folder and deletes them IF there is a .img or .iso or .mp4 file in the same folder.
- Code: Select all
on hazelProcessFile(theFile, inputAttributes)
tell application "System Events"
set rarfiles to name of theFile whose name ends with ".rar"
set notRarFiles to name of theFile whose name ends with ".iso" or name ends with ".img" or name ends with ".mp4"
set i to 0
repeat with aName in notRarFiles
set i to i + 1
set item i of notRarFiles to text 1 thru -5 of aName
end repeat
repeat with aRarFile in rarfiles
if text 1 thru -5 of aRarFile is in notRarFiles then delete theFile aRarFile
end repeat
end tell
end hazelProcessFile
Here is the original applescript
- Code: Select all
set theFolder to ((choose folder) as text)
tell application "System Events" to tell folder theFolder
set rarfiles to name of files whose name ends with ".rar"
set notRarFiles to name of files whose name ends with ".iso" or name ends with ".img" or name ends with ".mp4"
set i to 0
repeat with aName in notRarFiles
set i to i + 1
set item i of notRarFiles to text 1 thru -5 of aName
end repeat
repeat with aRarFile in rarfiles
if text 1 thru -5 of aRarFile is in notRarFiles then delete file aRarFile
end repeat
end tell