### Install macos-tags Source: https://github.com/dmkskn/macos-tags/blob/master/README.md Install the library using pip. Ensure you are using Python 3.7 or later. ```bash pip install macos-tags ``` -------------------------------- ### Get all tags Source: https://github.com/dmkskn/macos-tags/blob/master/README.md Retrieve all available tags on the system. This function returns a list of Tag objects. ```python import macos_tags macos_tags.tags() ``` -------------------------------- ### Get All Tags for a File Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Retrieves all tags currently assigned to a given file path. The result is a list of Tag objects, which may include color information. ```python >>> path = "/path/to/file" >>> macos_tags.get_all(path) [Tag(name='design', color=None), Tag(name='python', color=] ``` -------------------------------- ### Add a tag to a file (string name) Source: https://github.com/dmkskn/macos-tags/blob/master/README.md Add a tag to a file using its string name. If the tag does not exist, it will be added without a color. ```python path = "/path/to/file" macos_tags.add("design", file=path) ``` -------------------------------- ### Add a New Color Tag using String Format Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Adds a tag with a specified color to a file by formatting the tag name and color number as a string separated by a newline character. The color number corresponds to the Color enumeration values. ```python >>> tag = f"python\n{Color.GREEN}" # == "python\n2" >>> macos_tags.add(tag, file=path) ``` -------------------------------- ### Add a New Color Tag using Tag Class Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Adds a new tag with a specific color to a file using the Tag data class and Color enumeration. Requires importing Tag and Color from 'macos_tags'. ```python >>> from macos_tags import Tag, Color >>> tag = Tag(name="python", color=Color.GREEN) >>> macos_tags.add(tag, file=path) ``` -------------------------------- ### Add a color tag to a file (Tag object) Source: https://github.com/dmkskn/macos-tags/blob/master/README.md Add a tag with a specific color to a file by using the Tag data class and Color enumeration. ```python from macos_tags import Tag, Color tag = Tag(name="python", color=Color.GREEN) macos_tags.add(tag, file=path) ``` -------------------------------- ### Add a Tag to a File Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Adds a tag to a specified file. If the tag is a string and does not exist, it will be added without a color. Requires the file path and tag name. ```python >>> macos_tags.add("design", file=path) ``` -------------------------------- ### Find Files by Tag Name Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Use this function to retrieve a list of file paths associated with a specific tag. Requires the 'macos_tags' library to be imported. ```python >>> import macos_tags >>> macos_tags.find("design") ['/Users/home/apple.jpg', '/Users/home/WEB_POSTERS.png'] ``` -------------------------------- ### Count Files by Tag Name Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage This function returns the total number of files that have a specific tag. Ensure 'macos_tags' is imported. ```python >>> macos_tags.count("design") 2 ``` -------------------------------- ### Change All Tags on a File Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Replaces all existing tags on a file with a new list of tags. This is useful for bulk updates or resetting tags. Requires the file path and a list of Tag objects. ```python >>> macos_tags.get_all(path) [Tag(name='design', color=None), Tag(name='python', color=)] >>> 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", )] ``` -------------------------------- ### Remove a Tag from a File Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Removes a specific tag from a file. If the tag exists with a different color, the color will be updated. Requires the tag and file path. ```python >>> macos_tags.remove(tag, file=path) ``` -------------------------------- ### Remove All Tags from a File Source: https://github.com/dmkskn/macos-tags/wiki/Tutorial-&-Usage Removes all tags associated with a given file path. This operation is irreversible for the file's tags. ```python >>> macos_tags.remove_all(path) ``` -------------------------------- ### Remove a tag from a file Source: https://github.com/dmkskn/macos-tags/blob/master/README.md Remove a specific tag from a file. The tag can be specified as a string or a Tag object. ```python macos_tags.remove(tag, file=path) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.