Writing to -mditemfslabel tag for a directory (Mac OS)

Started by philbond87, October 29, 2020, 12:07:44 PM

Previous topic - Next topic

philbond87

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

Phil Harvey

Hi Phil,

Sorry, ExifTool operates only on files, not directories.

- 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

AppleScript can do it with ease but is probably OT. PM me if you want to follow up.

Phil Harvey

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
...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: 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.