My photo camera allows to save pictures in RAW and JPG in parallel. I find this convenient because on my Mac I can quickly browse the JPGs and delete the "bad" ones. Besides, I keep the RAW files of the "good" JPGs in case I need to do some deep editing.
I would like to write an AppleScript which deletes all the "bad" RAWs (RAW files which don't have a corresponding JPG anymore). All files are in the same directory.
This is my outline (far away from correct syntax!):
tell application "Finder" set source_folder to choose folder with prompt "Please select directory." my clearFiles(source_folder) end tell on clearFiles(source_folder) set theItems to "" tell application "System Events" set theItems to get the name of every disk item of source_folder end tell repeat with theFile in theItems if the extension of theFile is "raw" and exists name of theFile & ".jpg" then tell finder delete (name of theFile & ".raw") in source_folder and tell end if end tell end clearFiles