ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: philbond87 on October 29, 2020, 12:07:44 PM

Title: Writing to -mditemfslabel tag for a directory (Mac OS)
Post by: philbond87 on October 29, 2020, 12:07:44 PM
I can write to the -mditemfslabel tag to change the finder color label of files in Mac OS but how can I do that to a directory? (ignoring the files contained therein.) Is that possible?

Thanks,
Phil
Title: Re: Writing to -mditemfslabel tag for a directory (Mac OS)
Post by: Phil Harvey on October 29, 2020, 01:23:23 PM
Hi Phil,

Sorry, ExifTool operates only on files, not directories.

- Phil
Title: Re: Writing to -mditemfslabel tag for a directory (Mac OS)
Post by: Hubert on October 30, 2020, 07:19:40 PM
AppleScript can do it with ease but is probably OT. PM me if you want to follow up.
Title: Re: Writing to -mditemfslabel tag for a directory (Mac OS)
Post by: Phil Harvey on October 30, 2020, 09:36:37 PM
Yes.  In fact, this is what ExifTool does when writing this:

osascript -e 'set fp to POSIX file "$f" as alias' -e \\
  'tell application "Finder" to set comment of file fp to "$v"'


I suppose this may work for directories.

- Phil
Title: Re: Writing to -mditemfslabel tag for a directory (Mac OS)
Post by: Hubert on October 31, 2020, 09:40:04 AM
Quote from: Phil Harvey on October 30, 2020, 09:36:37 PM

I suppose this may work for directories.


It does.

The Finder colour label is referred to by the "label index" of the item (file or folder) and comes from an apparently arbitrary list:

No colour = 0
Orange = 1
Red = 2
Yellow = 3
Blue = 4
Purple = 5
Green = 6
Grey = 7

In straight AppleScript...

set the_folder to (choose folder)
tell application "Finder" to set label index of the_folder to 4


Will give the chosen folder a blue label, although the Finder display may not update immediately.