Skip to content

Commit

Permalink
Added findercolor
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Jul 14, 2021
1 parent 07b1082 commit f1cdf8c
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 234 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The command line tool can also be run via `python -m osxmetadata`. Running it w

```
Usage: osxmetadata [OPTIONS] FILE
Read/write metadata from file(s).
Options:
Expand Down Expand Up @@ -116,6 +116,10 @@ blue, yellow, red, orange. If color is not specified but a tag of the same
name has already been assigned a color in the Finder, the same color will
automatically be assigned.
com.apple.FinderInfo (finderinfo) value is a key:value dictionary. To set
finderinfo, pass value in format key1:value1,key2:value2,etc. For example:
'osxmetadata --set finderinfo color:2 file.ext'.
Short Name Description
authors kMDItemAuthors, com.apple.metadata:kMDItemAuthors; The
author, or authors, of the contents of the file. A list of
Expand Down Expand Up @@ -148,15 +152,22 @@ duedate kMDItemDueDate, com.apple.metadata:kMDItemDueDate; The date
zone), or 2020-04-14T12:00:00-07:00 (ISO 8601 with timezone
offset). Times without timezone offset are assumed to be in
local timezone.
findercomment kMDItemFinderComment,
com.apple.metadata:kMDItemFinderComment; Finder comments for
this file. A string.
finderinfo FinderInfo, com.apple.FinderInfo; Color tag set by the
findercolor findercolor, com.apple.FinderInfo; Color tag set by the
Finder. Colors can also be set by _kMDItemUserTags. This
is controlled by the Finder and it's recommended you don't
directly access this attribute. If you set or remove a
color tag via _kMDItemUserTag, osxmetadata will
automatically handle processing of FinderInfo color tag.
findercomment kMDItemFinderComment,
com.apple.metadata:kMDItemFinderComment; Finder comments for
this file. A string.
finderinfo finderinfo, com.apple.FinderInfo; Info set by the Finder,
for example tag color. Colors can also be set by
_kMDItemUserTags. com.apple.FinderInfo is controlled by the
Finder and it's recommended you don't directly access this
attribute. If you set or remove a color tag via
_kMDItemUserTag, osxmetadata will automatically handle
processing of FinderInfo color tag.
headline kMDItemHeadline, com.apple.metadata:kMDItemHeadline; A
publishable entry providing a synopsis of the contents of
the file. A string.
Expand Down Expand Up @@ -206,8 +217,9 @@ Information about commonly used MacOS metadata attributes is available from [App
|kMDItemDescription|description|com.apple.metadata:kMDItemDescription|A description of the content of the resource. The description may include an abstract, table of contents, reference to a graphical representation of content or a free-text account of the content. A string.|
|kMDItemDownloadedDate|downloadeddate|com.apple.metadata:kMDItemDownloadedDate|The date the item was downloaded. A datetime.datetime object. If datetime.datetime object lacks tzinfo (i.e. it is timezone naive), it will be assumed to be in local timezone.|
|kMDItemDueDate|duedate|com.apple.metadata:kMDItemDueDate|The date the item is due. A datetime.datetime object. If datetime.datetime object lacks tzinfo (i.e. it is timezone naive), it will be assumed to be in local timezone.|
|findercolor|findercolor|com.apple.FinderInfo|Color tag set by the Finder. Colors can also be set by _kMDItemUserTags. This is controlled by the Finder and it's recommended you don't directly access this attribute. If you set or remove a color tag via _kMDItemUserTag, osxmetadata will automatically handle processing of FinderInfo color tag.|
|kMDItemFinderComment|findercomment|com.apple.metadata:kMDItemFinderComment|Finder comments for this file. A string.|
|FinderInfo|finderinfo|com.apple.FinderInfo|Color tag set by the Finder. Colors can also be set by _kMDItemUserTags. This is controlled by the Finder and it's recommended you don't directly access this attribute. If you set or remove a color tag via _kMDItemUserTag, osxmetadata will automatically handle processing of FinderInfo color tag.|
|finderinfo|finderinfo|com.apple.FinderInfo|Info set by the Finder, for example tag color. Colors can also be set by _kMDItemUserTags. com.apple.FinderInfo is controlled by the Finder and it's recommended you don't directly access this attribute. If you set or remove a color tag via _kMDItemUserTag, osxmetadata will automatically handle processing of FinderInfo color tag.|
|kMDItemHeadline|headline|com.apple.metadata:kMDItemHeadline|A publishable entry providing a synopsis of the contents of the file. A string.|
|kMDItemKeywords|keywords|com.apple.metadata:kMDItemKeywords|Keywords associated with this file. For example, “Birthday”, “Important”, etc. This differs from Finder tags (_kMDItemUserTags) which are keywords/tags shown in the Finder and searchable in Spotlight using "tag:tag_name". A list of strings.|
|kMDItemParticipants|participants|com.apple.metadata:kMDItemParticipants|The list of people who are visible in an image or movie or written about in a document. A list of strings.|
Expand Down
21 changes: 14 additions & 7 deletions osxmetadata/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
import osxmetadata

from ._version import __version__
from .attributes import _LONG_NAME_WIDTH, _SHORT_NAME_WIDTH, ATTRIBUTES
from .attributes import (
_LONG_NAME_WIDTH,
_SHORT_NAME_WIDTH,
ATTRIBUTE_DISPATCH,
ATTRIBUTES,
)
from .backup import load_backup_file, write_backup_file
from .classes import _AttributeList, _AttributeTagsList, _AttributeFinderInfo
from .classes import _AttributeFinderInfo, _AttributeList, _AttributeTagsList
from .constants import (
_BACKUP_FILENAME,
_COLORNAMES_LOWER,
Expand Down Expand Up @@ -826,11 +831,13 @@ def process_single_file(
attribute_list = md.list_metadata()
for attr in attribute_list:
try:
attribute = ATTRIBUTES[attr]
value = md.get_attribute_str(attribute.name)
click.echo(
f"{attribute.name:{_SHORT_NAME_WIDTH}}{attribute.constant:{_LONG_NAME_WIDTH}} = {value}"
)
attribute_names = ATTRIBUTE_DISPATCH[attr]
for name in attribute_names:
attribute = ATTRIBUTES[name]
value = md.get_attribute_str(attribute.name)
click.echo(
f"{attribute.name:{_SHORT_NAME_WIDTH}}{attribute.constant:{_LONG_NAME_WIDTH}} = {value}"
)
except KeyError:
click.echo(
f"{'UNKNOWN':{_SHORT_NAME_WIDTH}}{attr:{_LONG_NAME_WIDTH}} = THIS ATTRIBUTE NOT HANDLED",
Expand Down
2 changes: 1 addition & 1 deletion osxmetadata/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" osxmetadata version """

__version__ = "0.99.20"
__version__ = "0.99.21"

0 comments on commit f1cdf8c

Please sign in to comment.