Create macos finder tags based on xmp metadata?

Started by duofuan, January 29, 2018, 09:42:50 AM

Previous topic - Next topic

duofuan

Hi I new here.

Firstly thank you Phil Harvey for the piece of amazing software.

I found myself in trouble and potentially exiftool could help me to deal with things.
I have few possible options and respectively questions (I will split them to two different topics to keep things clean).

So  here my question is:   
          Would be it possible to create finder tags based on xmp metadata of multiple files?
I know that creating xmp metadata from finder tags in possible with exiftool but I cannot find a thing about inverse posibility.

Thank you>

Duofuan

Phil Harvey

Hi Duofuan ,

Only a few of the MacOS tags are currently writable.  See the MacOS tags documentation for details.  I don't think it will currently write what you want.

- 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 ($).

duofuan

Thanks for a quick reply Phil.
I will look into another solution then.

Duofuan

Stephen Marsh

Please post back on your solution when you find it, thanks!

Phil Harvey

#4
I did some research into this.  Finder tags may be written from the Terminal with a "tag" utility.  I just installed this with:

brew install tag

> tag -h
tag - A tool for manipulating and querying file tags.
  usage:
    tag -a | --add <tags> <path>...     Add tags to file
    tag -r | --remove <tags> <path>...  Remove tags from file
    tag -s | --set <tags> <path>...     Set tags on file
    tag -m | --match <tags> <path>...   Display files with matching tags
    tag -l | --list <path>...           List the tags on file
    tag -f | --find <tags> <path>...    Find all files with tags (-A, -e, -R ignored)
  <tags> is a comma-separated list of tag names; use * to match/find any tag.
  additional options:
        -v | --version      Display version
        -h | --help         Display this help
        -A | --all          Display invisible files while enumerating
        -e | --enter        Enter and enumerate directories provided
        -R | --recursive    Recursively process directories
        -n | --name         Turn on filename display in output (default)
        -N | --no-name      Turn off filename display in output (list, find, match)
        -t | --tags         Turn on tags display in output (find, match)
        -T | --no-tags      Turn off tags display in output (list)
        -g | --garrulous    Display tags each on own line (list, find, match)
        -G | --no-garrulous Display tags comma-separated after filename (default)
        -H | --home         Find tagged files in user home directory
        -L | --local        Find tagged files in home + local filesystems
        -R | --network      Find tagged files in home + local + network filesystems
        -0 | --nul          Terminate lines with NUL (\0) for use with xargs -0


I could add the ability for Exiftool to write these tags via the "tag" utility if there is enough demand.

- Phil

Edit: "xattr" may also be used to write the Finder tags.  Although it is more complicated to use, you wouldn't need to install this utility.  See this page for more information.
...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 ($).

duofuan

Sounds like a great possibility for mac users!

duofuan

duofuan

Would this be easy to do with the current version of exiftools and the "tag" tool?
I.e recursively export chosen tags from all xmp tagged files in a directory? Making all tags searchable from within finder would be great!

duofuan

Phil Harvey

Hi duofuan,

You could use exiftool to create a script to do this:

exiftool -p 'tag -a "$keywords" $directory/$filename' -sep ',' DIR > add_tags.sh

then run "add_tags.sh" as a shell script to add the tags (with "source add_tags.sh").

Or as a one-liner:

exiftool -p 'tag -a "$keywords" $directory/$filename' -sep ',' DIR | source /dev/stdin

... but I think it would be prudent to look at the output of exiftool before executing it!

- 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 ($).

duofuan

Cool, tank you so much!
Going to try if this will save my workflow.

duofuan

Fulco

Quote from: Phil Harvey on January 30, 2018, 07:43:14 AM
I could add the ability for Exiftool to write these tags via the "tag" utility if there is enough demand.

This ability would be very useful for my workflow. I hope this will be implemented in the near future.

Best regards,
Fulco

Stephen Marsh

Quote from: duofuan on January 30, 2018, 12:15:12 PM
Making all tags searchable from within finder would be great!

duofuan

What metadata do you wish to search for in the Mac Finder? There is already support for various metadata fields, screenshot attached.

That being said, Apple sometimes mangle metadata:

http://prepression.blogspot.com.au/2016/01/metaconfusion.html