使用标记从Python组织Mac上的文件
macos-tags的Python项目详细描述
使用标记从Python组织Mac上的文件
安装
pip install macos-tags
从python3.7开始工作。在
教程
获取所有标记:
^{pr2}$按标记名获取文件:
>>>macos_tags.find("design")['/Users/home/apple.jpg','/Users/home/WEB_POSTERS.png']
按标记名计数文件:
>>>macos_tags.count("design")2
列出文件上的标记:
>>>path="/path/to/file">>>macos_tags.get_all(path)[Tag(name='design',color=<Color.NONE:0>),Tag(name='python',color=<Color.GREEN:2>]
向文件添加标记:
>>>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.
通过使用Tag
数据类和Color
枚举添加新的颜色标记:
>>>frommacos_tagsimportTag,Color>>>tag=Tag(name="python",color=Color.GREEN)>>>macos_tags.add(tag,file=path)
使用str
对象添加一个新的颜色标记,其中标记名称和颜色编号(从1到7)由文字\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.
从文件中删除标记:
>>>macos_tags.remove(tag,file=path)
立即从文件中删除所有标记:
>>>macos_tags.remove_all(path)
更改文件中的所有标记:
>>>macos_tags.get_all(path)[Tag(name='design',color=<Color.NONE:0>),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=<Color.NONE:0>),Tag("programming",<Color.BLUE:4>]
在❤️ 在
- 项目
标签: