Finder doesn’t like returns in comments …
Here’s an external Hazel script
-- External Hazel script: Set BBEdit Worksheet content as comment
on hazelProcessFile(theFile)
tell application "Finder"
try
set thisFile to file theFile
if (name extension of thisFile) = "worksheet" then
set thePath to POSIX path of (thisFile as text)
set theWorksheetContents to do shell script "/usr/libexec/PlistBuddy -c 'Print WorksheetContents' " & quoted form of thePath
if theWorksheetContents = "" then
set theWorksheetContents to "[content too long]" -- seems PlistBuddy has a limit
else if (count of characters in theWorksheetContents) > 256 then
set theWorksheetContents to (characters 1 thru 256 in theWorksheetContents) as string
end if
set cleanWorksheetContents to my replace_String(theWorksheetContents, return, space)
set comment of thisFile to cleanWorksheetContents
return true
else
return false
end if
on error error_message number error_number
if the error_number is not -128 then display alert "Hazel" message error_message as warning
return
end try
end tell
end hazelProcessFile
on replace_String(theText, oldString, newString)
local ASTID, theText, oldString, newString, lst
set ASTID to AppleScript's text item delimiters
try
considering case
set AppleScript's text item delimiters to oldString
set lst to every text item of theText
set AppleScript's text item delimiters to newString
set theText to lst as string
end considering
set AppleScript's text item delimiters to ASTID
return theText
on error eMsg number eNum
set AppleScript's text item delimiters to ASTID
error "Can't replaceString: " & eMsg number eNum
end try
end replace_String