Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Commenting tools?

Commenting tools?
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 20, 2004, 01:47 PM
 
Are there any commandline tools that allow you to add comments to files? It would be nice to write a script to batch process a bunch of files.
     
Mac Elite
Join Date: Nov 2003
Location: Minnesota
Status: Offline
Reply With Quote
Feb 20, 2004, 02:05 PM
 
What do you mean "Add comments to files"? Do you want to add a header of comments to a bunch of C files? How complicated is the task?
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 20, 2004, 07:03 PM
 
Instead of having to select a file in the finder and hit cmd-I to add a comment I was wondering if this could be done with a command line tool.
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Feb 21, 2004, 05:22 PM
 
I don't know, but I would love such a tool. Someone proficient in Carbon could probably whip one up in thirty minutes...
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 21, 2004, 05:37 PM
 
Is there a reason it has to be a Carbon app?
     
Mac Elite
Join Date: Feb 2001
Location: Washington, DC
Status: Offline
Reply With Quote
Feb 21, 2004, 05:57 PM
 
You could probably do it with Apple Script...
/Earth\ Mk\.\ I{2}/
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Feb 21, 2004, 06:26 PM
 
This is scriptable through the Finder. A file is a a subclass of the item class. Item has the comment property which can be read or written to. Here is an example script to get you started.
Code:
set _file to choose file set _comment to "" set _name to "" tell application "Finder" set _comment to comment of _file set _name to name of _file end tell display dialog "The comment in Get Info of file " & _name & " is: " & _comment buttons{"OK"}
To change or add a comment edit the line 'set _comment to ""' to 'set comment to 'my comment'. Then change the line 'set _comment to comment of _file' to 'set comment of _file to _comment'

Use a repeat loop to do a batch of files. You could create a list of different comments, and base which one is added on file name, suffix, date modified or created, label, size, location...lots of possibilities.

HTH
Craig
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 21, 2004, 08:19 PM
 
Tcsh users can just put
Code:
alias setcomment osascript -e "'"'tell application "Finder" to set comment of alias POSIX file "'\!:2\*'" to "'"'\!^'"'"'"'" alias getcomment osascript -e "'"'tell application "Finder" to return comment of alias POSIX file "'\!\*'"'"'"
in their ~/.cshrc or ~/.tcshrc file (bash users know what to do instead).

You have then two new aliases: getcomment <file> returns the comment of a file, setcomment <comment> <file> sets a file comment.

Note:
  • You have to put the comment in quotes if it contains spaces or any special characters for the shell
  • You cannot use wildcards in the filename
  • There is no special error handling
  • Don't ask me about the quotes

-
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Feb 22, 2004, 06:50 AM
 
And how would OnMyCommand CM users phrase it?
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Mar 1, 2004, 09:21 PM
 
Ran across this and thought I would pass it along:
http://sveinbjorn.vefsyn.is/osxutils
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2