I want to fine-tune some handlers I use as part of a larger script and it was suggested I break-down my requests on a handler-by-handler basis if possible. What I’m seeking is better ways to do these things if possible. I’m not interested in exercises in “do this all in one line of code” (that stuff is cool, but hard to comment and troubleshoot in my environment), just general efficiencies.
This handler writes a comment in the Get Info window (OS X Tiger). It detects existing comments and leaves them there and append the new comment. Is there a better way to do this?
Thanks in advance for any help provided, of course!
-- Finder comment editor
--
on finderCommenter(path_to_file, add_this_text)
tell application "Finder"
set existing_comments to (comment of path_to_file)
--check for existing comments
if existing_comments = "" then
set new_comments to add_this_text
else
set new_comments to existing_comments & return & add_this_text
end if
--write updated comments
set comment of path_to_file to new_comments
end tell
end finderCommenter