{"id":13585393,"url":"https://github.com/dmkskn/macos-tags","last_synced_at":"2025-04-07T09:34:41.406Z","repository":{"id":62577288,"uuid":"235347181","full_name":"dmkskn/macos-tags","owner":"dmkskn","description":"A python library to manipulate tags on macOS","archived":false,"fork":false,"pushed_at":"2020-03-02T12:47:58.000Z","size":89,"stargazers_count":26,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-23T04:09:42.532Z","etag":null,"topics":["macos","macos-tags","python"],"latest_commit_sha":null,"homepage":"https://macos-tags.dmkskn.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmkskn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-21T13:18:54.000Z","updated_at":"2024-06-24T16:02:16.000Z","dependencies_parsed_at":"2022-11-03T19:15:19.060Z","dependency_job_id":null,"html_url":"https://github.com/dmkskn/macos-tags","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmkskn%2Fmacos-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmkskn%2Fmacos-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmkskn%2Fmacos-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmkskn%2Fmacos-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmkskn","download_url":"https://codeload.github.com/dmkskn/macos-tags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223277847,"owners_count":17118655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["macos","macos-tags","python"],"created_at":"2024-08-01T15:04:54.989Z","updated_at":"2024-11-06T03:31:02.338Z","avatar_url":"https://github.com/dmkskn.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Use tags to organize files on Mac from Python\n\n![Release](https://github.com/dmkskn/macos-tags/workflows/Release/badge.svg)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n\n## Installation\n\n```bash\npip install macos-tags\n```\n\nWorks since Python 3.7.\n\n## Tutorial\n\nGet all tags:\n\n```python\n\u003e\u003e\u003e import macos_tags\n\n\n\u003e\u003e\u003e macos_tags.tags()\n[Tag(name='design', color=\u003cColor.NONE: 0\u003e), ..., Tag(name='python', color=\u003cColor.GREEN: 2\u003e]\n```\n\nGet files by tag name:\n\n```python\n\u003e\u003e\u003e macos_tags.find(\"design\")\n['/Users/home/apple.jpg', '/Users/home/WEB_POSTERS.png']\n```\n\nCount files by tag name:\n\n```python\n\u003e\u003e\u003e macos_tags.count(\"design\")\n2\n```\n\nList the tags on the file:\n\n```python\n\u003e\u003e\u003e path = \"/path/to/file\"\n\n\u003e\u003e\u003e macos_tags.get_all(path)\n[Tag(name='design', color=\u003cColor.NONE: 0\u003e), Tag(name='python', color=\u003cColor.GREEN: 2\u003e]\n```\n\nAdd a tag to file:\n\n```python\n\u003e\u003e\u003e macos_tags.add(\"design\", file=path)\n```\n\n\u003e 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.\n\nAdd a new color tag by using `Tag` data class and `Color` enumeration:\n\n```python\n\u003e\u003e\u003e from macos_tags import Tag, Color\n\n\n\u003e\u003e\u003e tag = Tag(name=\"python\", color=Color.GREEN)\n\n\u003e\u003e\u003e macos_tags.add(tag, file=path)\n```\n\nAdd 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`:\n\n```python\n\u003e\u003e\u003e tag = f\"python\\n{Color.GREEN}\"  # == \"python\\n2\"\n\n\u003e\u003e\u003e macos_tags.add(tag, file=path)\n```\n\n\u003e If the tag already exists in the system with a different color, the new color will be ignored.\n\nRemove tag from file:\n\n```python\n\u003e\u003e\u003e macos_tags.remove(tag, file=path)\n```\n\nRemove all tags from a file at once:\n\n```python\n\u003e\u003e\u003e macos_tags.remove_all(path)\n```\n\nChange all tags in the file:\n\n```python\n\u003e\u003e\u003e macos_tags.get_all(path)\n[Tag(name='design', color=\u003cColor.NONE: 0\u003e), Tag(name='python', color=\u003cColor.GREEN: 2\u003e]\n\n\u003e\u003e\u003e new_tags = [Tag(\"book\"), Tag(\"programming\", Color.BLUE)]\n\n\u003e\u003e\u003e macos_tags.set_all(new_tags, file=path)\n\n\u003e\u003e\u003e macos_tags.get_all(path)\n[Tag(name=\"book\", color=\u003cColor.NONE: 0\u003e), Tag(\"programming\", \u003cColor.BLUE: 4\u003e]\n```\n\n❤️","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmkskn%2Fmacos-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmkskn%2Fmacos-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmkskn%2Fmacos-tags/lists"}