News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

is there another "comment" tag appearing in "get info" in Mac computer?

Started by lsolesbee, February 21, 2017, 07:09:56 AM

Previous topic - Next topic

lsolesbee

I saw the -comment tag in samples and jumped to the wrong conclusion that data entered in that tag would show up in the comment field in the "get info" popup in my Mac computer, or if I use the LIST view in Finder adding "comment" to the view options.

After using that command many times,  it never entered the any data into the comment.

I tried this sample from instructions:
exiftool '-comment<ISO=$exif:iso Exposure=${shutterspeed}' dir

what I was trying to do:
exiftool '-comment<CamModel=${model;}'  dir

even a few times trying "usercomment"

it was only after many iterations that I finally saw the "comment" field in the exif viewer.
and also the usercomment, and my sample text was in each of those fields.

then I read about xpcomment for Windows computer. (I'm using a Mac)
before trying that, listing all,  -a for a photo gave me a list of a hundred tags including comment and usercomment.

after trying xpcomment, doing another -a gave me that list, but adding the xpcomment field.

copying that photo to my Windows computer, viewing the photo with file explorer, I do see the test text in the comment field.


so, IS THERE A TAG that will write and read text in the info popup COMMENT field/ finder comment on my Mac?

exiftool ver 10.42 on Mac OS X v 10.9.5 (Maverick) w proc 2x2.8Ghz Quad-core Intel Xeon

Phil Harvey

The comment displayed in the OS X File Info Comments is not stored in the file, and ExifTool can't set this.  But ExifTool can be used to read this information:

exiftool -MDItemFinderComment FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

lsolesbee

thanks for that info.
do you know of any utility that could read some exif data and paste it into that OS X File Info Comment?

just doing some testing.
yesterday I had manually put the text "shut up" into the file info comments of 3 files in test folder
looking at them today, they are blank
so I added a short description into those 3 file info comments and then ran your command:tt    exiftool -MDItemFinderComment DIR

that command listed all 20 files in that folder 17 showed nothing, but the 1st three showed "shut up" as the Comment, even though I had entered different comments. Where could it find that old replaced comment?

I manually added comments to a couple other files and ran command again. It did show those new comments, but still showed "shut up" on the 1st 3 files.

====
add: now 10 minutes later looking at Finder listing of that folder, I see the 1st 3 files comments were updated to that which I manually added today. Interesting delay, wonder where those old comments were stored until the delay replaced with today's comments.

Phil Harvey

I can't answer your question about the Mac system metadata, but you can run the Mac "mdls" command-line utility yourself to list the system metadata for a file.  This is what ExifTool does to get this information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hubert

Late to the party...

You can modify Finder comments using AppleScript, e.g.

tell application "Finder" to set comment of file (choose file) to "Something different"

And AppleScripts can be run as terminal commands using osascript - although escaping quote marks can be challenging.

Hope that is helpful.

lsolesbee

thanks for info on using apple script to add text to finder comment, but can it read data from exif data to put that data into the comment, where each file could have different data? For example read the camera model from exif data and insert that model name/number into the finder comment for an entire folder of photos?

Phil Harvey

Thanks for this tip.  Using your technique, ExifTool 10.45 will have the ability to write the MDItemFinderComment tag.

- Phil

Edit:  I will also add the ability to write MDItemFSCreationDate and MDItemFSLabel.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hubert

Quote from: lsolesbee on February 28, 2017, 03:09:31 AM
thanks for info on using apple script to add text to finder comment, but can it read data from exif data to put that data into the comment, where each file could have different data? For example read the camera model from exif data and insert that model name/number into the finder comment for an entire folder of photos?

Yes it can, but it's not entirely trivial.

You can run shell scripts from within AppleScripts using the "do shell script" command.

So if you incorporated an exiftool command into an AppleScript, you could loop through each file in the folder, extract the exif data to a variable using an ExifTool command, and then tell Finder to set the file comment.

I'll attempt to create an example - it may take a day or two.

Hubert

It was quicker than I thought. The AppleScript below uses ExifTool to extract the camera make and model from images in a chosen folder, then parses the output text and writes the make and model to the Finder comment for each file. BEWARE - it will overwrite any pre-existing comments, so TEST ON COPIES. If you want to add the data to any existing comment, this is relatively simple, but the script below is a proof of concept.

I'm a bit out of practice with AppleScript and I suspect that there are simpler ways of defining the file paths. And parsing text in AppleScript is always a bit clunky. But here goes... launch Script Editor, copy and paste this into a new window and click Run.

--begin script
set the_folder to (choose folder with prompt "Choose a folder full of images")
set folder_path to quoted form of POSIX path of the_folder as string --UNIX path of the folder
set exif_data to (do shell script "/usr/local/bin/exiftool -make -model " & folder_path) -- extracts the exif data as text
--parse the exif data, paragraph by paragraph:
set AppleScript's text item delimiters to ": " -- used to split the paragraphs into chunks
set parcount to count paragraphs in exif_data -- each paragraph is a line of the ExifTool output
repeat with x from 1 to parcount -- loop through each paragraph in turn
   set next_par to paragraph x of exif_data
   if next_par contains "===" then --this line contains the file path
      set path_start to offset of "/" in next_par -- first character of path
      set file_path to text path_start thru -1 of next_par --complete path as text
      set the_file to POSIX file (file_path) as alias -- convert unix path to a format that the Finder can understand later
      set make_par to paragraph (x + 1) of exif_data -- next paragraph contains the camera make
      set the_make to text item 2 of make_par -- the chunk after the colon and space
      set model_par to paragraph (x + 2) of exif_data -- this paragraph contains the camera model
      set the_model to text item 2 of model_par -- the chunk after the colon and space
      set make_model to the_make & space & the_model -- concatenate make and model with a space between
      tell application "Finder" to set comment of the_file to make_model -- set Finder comment
   end if
end repeat
-- end script

Phil Harvey

@lsolesbee:  Sorry I didn't answer your question.  If you can wait a few days for ExifTool 10.45 you can use this command to copy EXIF:UserComment to the OS X comments:

exiftool "-MDItemFinderComment<UserComment" DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

UKenGB

Quote from: Phil Harvey on February 28, 2017, 07:59:49 AM
Thanks for this tip.  Using your technique, ExifTool 10.45 will have the ability to write the MDItemFinderComment tag.

- Phil

Resurrecting this topic, but my question is directly related.

Reading and writing of Finder comments is now possible with MDItemFinderComment which is great, but as far as I can see, writing only works when it is the only tag supplied in the command. If it is one of several other tags to be updated, the Finder comments are not touched.

Am I missing something or is this just how it works? Any chance of making it operate like the other tags so it can be used as one of many tags to update?

StarGeek

This note on the MacOS tags page may be relevant

    Note that these tags do not necessarily reflect the current metadata of a file -- it may take some time for the MacOS mdworker daemon to index the file after a metadata change.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

UKenGB

Thanks, but no that's not it.

If I update a file just setting MDItemFinderComment, the Finder Comments are immediately updated and visible. If I also include any other tags to update, they get updated, but the Finder Comments do not get changed, at all, ever. Whichever order I place the tags on the command line, if there's more then just -MDItemFinderComment='foobar' (or whatever), the comments just don't get updated.

Right now it would make my life a whole lot easier if I could update the file once with all those tags (including MDItemFinderComment) all in one go.

Phil Harvey

This works for me on MacOS Mojave with the current version of ExifTool:

% exiftool a.jpg -comment -MDItemFinderComment
% exiftool a.jpg -comment=one -MDItemFinderComment=two
    1 image files updated
% exiftool a.jpg -comment -MDItemFinderComment
Comment                         : one
MD Item Finder Comment          : two


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

UKenGB

Quote from: Phil Harvey on February 08, 2020, 07:15:07 PM
This works for me on MacOS Mojave with the current version of ExifTool:
...
- Phil

Aha. I'm using 11.45 I think, so I'll try the latest (11.86) and see. It'll be great if it does work for me.

I have another question, but not Finder Comments related so I'll post a new topic.

Phil Harvey

I don't see any changes since 11.45 that would affect this, but try the latest version just in case.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).