property verbose : false on open of theFiles repeat with aFile in theFiles my fix(aFile) end repeat end open on run display dialog "You need to drop the files onto this script saved as an application" buttons "OK" default button "OK" end run on fix(f) local c, p, c2 tell application "Finder" set c to comment of f end tell set p to quoted form of POSIX path of f try set c2 to do shell script "xattr -x -p com.apple.metadata:kMDItemFinderComment " & p & " | xxd -r -p | plutil -p -" set c2 to (characters 2 thru -2 of c2) as string -- trim the quotes around the shell cmd's result on error set c2 to "" end try if c = c2 or convertToLF(c) = convertToLF(c2) then if verbose then if c = "" then display dialog "Comment is empty" buttons "OK" default button "OK" else display dialog "Comment is intact" buttons "OK" default button "OK" end if end if else tell application "Finder" set comment of f to "" set comment of f to c update f end tell try set c2 to do shell script "xattr -x -p com.apple.metadata:kMDItemFinderComment " & p & " | xxd -r -p | plutil -p -" set c2 to (characters 2 thru -2 of c2) as string -- trim the quotes around the shell cmd's result on error set c2 to "" end try if c = c2 or convertToLF(c) = convertToLF(c2) then if verbose then display dialog "Comment was fixed" buttons "OK" default button "OK" end if else display dialog "Comment can't be fixed: " & return & p & return & "<" & c & ">" & return & "--" & return & "<" & c2 & ">" buttons "OK" default button "OK" end if end if end fix on convertToLF(s) set AppleScript's text item delimiters to return set the item_list to every text item of s set AppleScript's text item delimiters to linefeed set s to the item_list as string set AppleScript's text item delimiters to "" return s end convertToLF