 |
 |
Commenting tools?
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
Is there a reason it has to be a Carbon app?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Washington, DC
Status:
Offline
|
|
You could probably do it with Apple Script...
|
|
/Earth\ Mk\.\ I{2}/
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Oct 2000
Location: Midwest
Status:
Offline
|
|
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
|
|
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
|
|
And how would OnMyCommand CM users phrase it?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|