Skip to main content

Use tags to organize files on Mac from Python

Project description

Use tags to organize files on Mac from Python

Release Checked with mypy

Installation

pip install macos-tags

Works since Python 3.7.

Tutorial

Get all tags:

>>> import macos_tags


>>> macos_tags.tags()
[Tag(name='design', color=None), ..., Tag(name='python', color=<Color.GREEN: 2>]

Get files by tag name:

>>> macos_tags.find("design")
['/Users/home/apple.jpg', '/Users/home/WEB_POSTERS.png']

Count files by tag name:

>>> macos_tags.count("design")
2

List the tags on the file:

>>> path = "/path/to/file"

>>> macos_tags.get_all(path)
[Tag(name='design', color=None), Tag(name='python', color=<Color.GREEN: 2>]

Add a tag to file:

>>> macos_tags.add("design", file=path)

When using str objects to define a tag, if a tag does not exist in the system, it will be added without a color label.

Add a new color tag by using Tag data class and Color enumeration:

>>> from macos_tags import Tag, Color


>>> tag = Tag(name="python", color=Color.GREEN)

>>> macos_tags.add(tag, file=path)

Add a new color tag using the str object, where the tag name and color number (from 1 to 7) are separated by the literal \n:

>>> tag = f"python\n{Color.GREEN}"  # == "python\n2"

>>> macos_tags.add(tag, file=path)

If the tag already exists in the system with a different color, the new color will be ignored.

Remove tag from file:

>>> macos_tags.remove(tag, file=path)

Remove all tags from a file at once:

>>> macos_tags.remove_all(path)

Change all tags in the file:

>>> macos_tags.get_all(path)
[Tag(name='design', color=None), Tag(name='python', color=<Color.GREEN: 2>]

>>> new_tags = [Tag("book"), Tag("programming", Color.BLUE)]

>>> macos_tags.set_all(new_tags, file=path)

>>> macos_tags.get_all(path)
[Tag(name="book", color=None), Tag("programming", <Color.BLUE: 4>]

❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

macos-tags-1.4.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

macos_tags-1.4.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file macos-tags-1.4.2.tar.gz.

File metadata

  • Download URL: macos-tags-1.4.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.7.6 Darwin/19.2.0

File hashes

Hashes for macos-tags-1.4.2.tar.gz
Algorithm Hash digest
SHA256 01d527f6a0c45da3b5fb37a98c743532bb216ef13c0ede87c17066b6e44c47e1
MD5 9a866078d9febde802cb69a1143c8f89
BLAKE2b-256 951e27061021851dde1a30165cb8d7db290303922c346cdd4f5f3370a8a071a4

See more details on using hashes here.

File details

Details for the file macos_tags-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: macos_tags-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.7.6 Darwin/19.2.0

File hashes

Hashes for macos_tags-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 062e469cd46642cf0f432845cf32c05978a11bcfbfc1b945e5f8ddcf9aa1f57b
MD5 9e84588af4301d210929bbcffaacdc5a
BLAKE2b-256 5d4e3a941fefb2f6279a58086606e5f38198eb374998eff8d7dabc2924e73817

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page