jdberry / tag Goto Github PK
View Code? Open in Web Editor NEWA command line tool to manipulate tags on Mac OS X files, and to query for files with those tags.
License: MIT License
A command line tool to manipulate tags on Mac OS X files, and to query for files with those tags.
License: MIT License
Could you add an option to the list argument that puts a delimiter between the file name and the tags? It's a hassle to parse out the files and any tags that may exist. Also if the file name is a directory could you append a trailing slash to the name so it's obvious what is a file and what isn't? That would be greatly appreciated.
Very nice application by the way!
Dear James,
Could you be so kind to generate .exe
for the rest of us who use Windows, if possible?
My environment:
I tried to add tag to a file from Terminal this way:
$ tag -l "/Users/me/Downloads/Virtual Barber Shop Hair Cut - 3D Sound (Amazingtag!!) (Low).mp4"
and here is the error messages:
tag -l "/Users/me/Downloads/Virtual Barber Shop Hair Cut - 3D Sound (Amazingtagtag -l "/Users/me/Downloads/Virtual Barber Shop Hair Cut - 3D Sound (Amazingtag -h) (Low).mp4") (Low).mp4"
-bash: syntax error near unexpected token `('
Looks like tag's argparse has problems with special characters in the path.
Please help.
Finder seems to have a fast method for listing all tags in use in the filesystem. It would be very helpful to add support in the 'tags' command. It can be faked (slowly) using 'tag --find * --tags --no-name' and processing the results but a fast, simple method would be extremely useful.
If the tag command creates a new tag on a network file/directory, that tag will not be listed under the Finder "All Tags..." until the tag command adds the same tag to a local file/directory, or the Finder adds the same tag to a local/network file/directory.
The tag created on the network resource in this scenario remains in an ephemeral state, wherein the Finder cannot delete and readd the tag. If some other process successfully adds the tag, then the ephemeral nature of the original tag is resolved.
To expound on what I mean by ephemeral, the graphics of the tag will be a dotted line instead of a solid line. I can create a similar dotted line graphic by introducing a new tag in the Finder, before the tag edit bubble is closed.
I cannot find any intuition on whether this is a tag command thing, an osx thing, or both. The state machine of the tag command is a mystery! I'll understand if there's nothing to be done.
My use case here is that I drag music files/folders onto tags as genres, and then later I use your tag command to dump the tag list and assign those files/folders per tag into a playlist per tag. At home I have a mac mini in the closet with the music, which I sort from a remote client and then generate the playlists. If a new tag is introduced on the mac mini, it will not be presented on my computer until I manually munge in the tag with trickery. Thanks.
I'm trying to call tag from within another application, and when I do, it's dying with "The operation couldn't be completed. (OSStatus error -43.)". When I try to call tag from within a shell script, it throws the same error.
It would be useful to be able to find files that currently don't have tags. As far as I see there is no real way in order to do this, and it would make scripting easier.
Not sure exactly what you mean by this:
• Tagnames may include spaces, but the entire tag list must be provided as one parameter: "a multiword tag name".
Do you mean that if any tag in the list contains a space, the entire list must be enclosed in double quotes? Or do you mean that each tag that contains a space must be individually quoted?
It would be the difference between this:
"tag1,tag2,tag3 with spaces,tag4"
and this:
tag1,tag2,"tag3 with spaces",tag4
Or do you mean something else? Please clarify, and thanks for making this software!
Hey there,
I try to do some stuff with iTunes and your tag command line. I have the following written in Applescript:
do shell script "/usr/local/bin/tag --set 'Electro House' '~/Music/iTunes/iTunes Media/Music/Alex Skrindo/Moments/Moments (feat. Stahl!).mp3'"
The tag should be "Electro House" and the file does exist at the specific location, I already checked that. But the problem is that if I type it right into the command line it works but if I call it like in the code snippet above, I always get following error message:
tag: The operation couldn’t be completed. (OSStatus error -43.)
As far as I am aware of the error code 43 has something to do with the existence of the file. But those files to all exist. Maybe you have a clue. Obviously the command itself works but not if I call it through Applescript even if they both are technically the same...
EDIT:
The above command does not work in the terminal. Just tags without spaces do work for me...
According to the readme:
The --all, --enter, and --recursive options apply to --add, --remove, --set, --match, and --list
I need to --find invisible tags. Is there a workaround for this?
Is there a way to list all files in a folder, separated by tag? For example:
tag
Name1
Name2
Name3
tag
Name1
Name2
Name3
Name4
tag
Name1
Name2
i know that tag -tgf \* /Some/Folder
will show files in the folder with any tag.
i know that tag -tgf \*|grep '^ '|cut -c5-|sort -u
will list all Finder tags
I would like to a combination of the two without having to call out each tag-
( tag -tgf 'tagname' /Some/Folder
)
Is this possible, or maybe even with a small script?
Thanks very much
The default action, when none is specified, has been set to --list
. It also does this when --help
and --version
are specified — so the current directory contents are listed after the version is printed, or the help text is displayed.
Hello,
tag v0.8.1 doesnt seem to work on an external USB 4 Tbytes Harddisk, that is mounted R/W by Paragon NTFS v12.1.62.(Macbook pro, 10.10.3, tag installed via port)
It looks to me as if it doesnt even access the Volume, i hear no sound, and there is no delay, e.g. "tag --find '*' --descend /Volumes/4T", and of course no matching files are output.
This is not a permissions issue, because in Finder i can create, edit and delete files(as well as their tags) on said drive easily.
I should mention that cocatech's PathFinder 7.1.5 shows some strange behaviour too on NTFS Volumes (shows, but is unable to change tags).
Any idea on this ?
Any way to force a verbose/debug output or dump a logfile that i could send to you?
Yours
Dirk
If you could add this syntax example to your documentation to help others (although, it relies on gnu xargs
). I haven't figured out how to pipe a list of filenames into tag
using macOS installed xargs
.
$ gxargs -d '\n' -a /Users/name/Desktop/textfile.txt -I % tag -a red %
Here we use xargs
to read from file (using -a
), using replacing string with (using %
) and execute command tag -a red {filename}
. You may need to add -d '\n'
(setting delimiter to newline) to split strings.
This allows us to use the two flags -d
and -a
there fore we don't need to add the -0
flag in xargs
and tag
.
-a file, --arg-file=file
Read items from file instead of standard input. If you use this option, stdin remains unchanged when commands are run. Otherwise, stdin is redirected
from /dev/null.
--delimiter=delim, -d delim
Input items are terminated by the specified character. The specified delimiter may be a single character, a C-style character escape such as \n, or an
octal or hexadecimal escape code. Octal and hexadecimal escape codes are understood as for the printf command. Multibyte characters are not supported.
When processing the input, quotes and backslash are not special; every character in the input is taken literally. The -d option disables any end-of-file
string, which is treated like any other argument. You can use this option when the input consists of simply newline-separated items, although it is al-
most always better to design your program to use --null where this is possible.
gnu xargs can be installed on mac using homebrew command brew install findutils
It would be useful to have a way to find files with tags matching a regex. As far as I understand there is no way to do it now.
I have been using jdberry/tag in a generated script, which has thousands of lines like this: tag --set tag1,tag2 file
. It'd be nice if I could do something like tag --verbose
so I can see what's going on. Otherwise, it runs silently, which is great, but it'd be nice to have some form of reference as to how much longer it has to go. If this is already possible, I apologize. I looked for it but I didn't see it.
On several times now, I have encountered a situation where after adding a tag to a PDF file in a shell script with
tag -a "$tags" "$file"
the file was damaged as a result. With a hex editor, I could see that the beginning of the file was overwritten by the xattr information (bplist00
etc.)
It is the same when I enter the command above in the Terminal, replacing the variables with their actual values.
This is seemingly caused by certain characters in the tag, but I have not found out which ones.
Using Tag 0.9 installed through Homebrew on OS X 10.11.6
This is a very useful tool. Unfortunately, no matter what I do I can't pipe it to xargs. Something in the readme said to use -0. But although this clearly changes the format of the output, whether or not I have it I always only get xargs: unterminated quote
.
In the meantime I will look for a workaround. If anyone can share how they process the raw output without xargs perhaps that could help me too.
Hi I would like to list tags of a set of files, possibly all the tagged files in my computer, and list these tags according to the date of last use.
I may assume that the last use corresponds to the latest modification time of files tagged with a given tag, but this is an assumption ... is the tagging "history" somehow accessible anywhere?
Hi,
I would like to copy the tags set on one file to another file. I am a bit lost how to do it though... Maybe you could even add this functionality?
I did an automator action "encode to m4a 128kbit". But I would like to then copy the tags set for the wav file to the generated m4a file.
Very strange btw. that there are no tools from Apple. Finder tags seems to be super rudimentary a.k.a. almost useless.
Hi, I wrote a small Formula to install tag with Homebrew. (Homebrew/legacy-homebrew@debb6bd)
brew install tag
Just to let you know 😄
I read the entire README.md and all the issues. But I failed to figure out how to show all tag names that I added/used. I thought it should be a basic feature but don't know how to do it. If I add thousands of tags, I won't be able to memorize all tag names so I need a way to figure out what tags are. Thanks a lot.
This command is working to reveal every file in the directory that has any tag.
tag --match '*' --recursive --tags /Volumes/PlexMedia
When I try to remove all of the tags I found I get an error:
$ tag --remove 'Green' --recursive /Volumes/PlexMedia
tag: The operation couldn’t be completed. (OSStatus error -5000.)
I first thought it could be an ownership issue. The volume didn't have "ignore ownership on this volume" selected. I checked that and ran the command again and received the same error. I then selected "apply to enclosed items" and ran the command again.
Is my command incorrect?
$ tag -r 'Green' -R /Volumes/PlexMedia
tag: The operation couldn’t be completed. (OSStatus error -5000.)
I am thinking I need to pass the found files to xargs but am having trouble with the syntax
$ tag --match '*' --recursive --tags /Volumes/PlexMedia | xargs -0 tag -r {}
$ tag --match '*' --recursive --tags /Volumes/PlexMedia | xargs -0 -I {} tag -r -R {}
$ tag --match '*' --recursive --tags /Volumes/PlexMedia | xargs -0 tag -r -R
tag: The item couldn’t be opened because the file name “The Big Short (2015) CD” is invalid.
I'm trying to recursively add a tag all the files and folders in a path, which is working perfectly except that I have added a simlink to a directory on an external read-only drive, and it's now giving me the error tag: The operation couldn’t be completed. (OSStatus error -8058.)
. Could you maybe add an option to not follow links?
The current tag --list file
output is hard to parse:
file tag1,tag2,...
It'd be much better to just output:
tag1
tag2
...
To not break backward-compatibility, I suggest adding --list-lines
for outputting like this.
While it's possible to add tags that differ only in case, Finder seems to collapse tags that differ only in case. We should probably follow suit and compare tags in a case-insensitive fashion when we add, remove, match, and find.
On https://github.com/jdberry/tag/blob/master/Tag/Tag.m#L385 there is some padding that gets put into the file output. This causes the filename to be invalid.
$ touch test1 test2
$ tag -a demo *
$ tag -m demo *
test1
test2
$ tag -0 -m demo * |xargs -0 ls -l
ls: test1 : No such file or directory
ls: test2 : No such file or directory
If I remove the padding and recompile, the program works as I expect it to. I am not a developer, and this is my first submission so please be kind if my report is bogus or my description poor. Regards!
Right now, if you add or edit tags recursively, it's also applied to the directories themselves.
It would be great if there was a flag or option to make it so that tag
will not add tags to directories.
It would be nice to be able to specify tags to ignore. For instance, say I tag some files as "archive". I could then run a search as normal but that do not include files tagged as archive. A sample of the command could look like this:
tag -f Red Yellow Blue -i archive
This would search for all files that have been tagged "Red", "Yellow", and "Blue", but that do not have the "archive" tag.
tag: The item couldn’t be opened because the file name “horizon.s55e01.we.need.to.talk.about.death.720p.hdtv.x264-qpel[eztv].mkv ” is invalid.
I might be missing something here, but the only way I can see to list all tags throughout the entire system is:
tag --usage
This lists all tags with their associated usage
I want to use tag
to get all available tags for a script in Alfred. It's easy enough to split the output of tag --usage
but it would be useful to just have a simple command that outputs all tags on their own. I've tried tag --list
but this seems to list folders as well.
.
Any ideas how to link 'tag' with with ranger?
I would need to assign tags to files that contain the comma character, but I cannot find a way to do that. I tried escaping with '', but this does not work.
The man page specifies that e.g. either -H
or --home
can be used to limit searching of tagged files:
-H | --home Find tagged files in user home directory
-L | --local Find tagged files in home + local filesystems
-R | --network Find tagged files in home + local + network filesystems
Using --home
works as expected:
$ tag --home -f Green
[…]/Desktop/test
But using --H
instead gives an error (while still providing results):
$ tag -H -f Green
tag: invalid option -- H
[…]/Desktop/test
Im using v0.8.1 installed via MacPorts.
First of all, this is a great utility. Thanks!
I'm trying to tag a bunch of movie files, and would like the "Year" tag to always be the first tag in the group. Other tags are actors, directors, and movie type.
Is there a way to control the order of the tag?
I've tried a few things, but it seems to always be a bit random.
Thanks!
Rixstep has released a new super-fast tagging app called Rixtag using proprietary xattr, not the default macOS tags: http://rixstep.com/1/20170808,00.shtml
The xattr is com.rixstep.Rixtag
, and the tags are stored in binary plist as hex data.
Support possible? E.g. as tag --xattr=com.rixstep.Rixtag <option> <tag(s)> <path(s)>
In that regard, wouldn't it be easy to let users create their own xattr? E.g.:
tag --xattr=com.github.jdberry -a <tag(s)> <path(s)>
and so on…
If I use the command tag --add "Important" myFile.docx
, it adds the tag "Important" to my file. However, the tag
tool also seems to remove the color information for display in the Finder for this tag. So in this instance, the "Important" tag is by default marked with a red dot, now it isn't marked as such anywhere in the Finder which is quite annoying.
Thanks for building this cool tool! I've installed on OSX Mojave via Homebrew.
Sometimes it works fine, and sometimes I get the following error:
feckless:/Volumes/Back> tag -a Red Exps/Analysis/Russian -R
tag: The operation couldn�t be completed. (OSStatus error -8058.)
Any thoughts on what's happening?
Thank you!
-Dianne
Right clicking and selecting remove tag does not work after tagging with the tool. It does work from the edit tags menu.
I seem to have no problem tagging files and directories, but when performing a query using find, only my tagged files show up. Is this expected, or is there another option to include directories?
$ find . -name ".vagrant" |xargs tag -s blah
$ tag -l .vagrant
.vagrant blah
$ find . -name "dummyfile" |xargs tag -s blah
$ tag --find blah .
<PATH_TO_MY_FILE>/dummyfile
Use the output of find as input to another script for further processing, but it needs to process tagged directories as well.
Thanks.
Seems that Tag command dont work with folder instead files. How i can get tags from a folder?
Thanks
First, thanks a lot for the amazing tool. I just install it today. I read a closed issue which mentions the tag uses extended attribute in HFS and APFS file systems. I don't really know what it means. Where does the tag info store? Does it store in the same file which I tag?
For example, if I tag a file tag -a tag1 file1
, and then later rm file1
, do the tag1
tag name and the reference/link btw tag name and file both removed from the file system? Do I need to do anything to clean the cache (or the extended attributes)?
Thanks a lot.
Please: could you add an option to find tags that use the com.apple.metadata:kMDItemOMUserTags
attribute?
If so, then would tag
work (for that purpose) with Mountain Lion?
Thanks
Hi,
I'm able to tag a specific file if I put its name it in the command line.
But what if I want to tag a bunch of files (or all the files) which are in the same folder without naming them one by one?
Thanks in advance for your help :)
Sylvain
The scope for the --find command, unless I am mistaken, can only be home, local, or volume. IIUC, the system call allows NSURLs as search scopes. Maybe this could be added into the tool? Perhaps something like --scope /path/to/dir/
, or tags --match --recursive <tags> <dir>...
I think this might be more efficient than a shell glob when searching through thousands of files.
Thanks!
Hi,
First of all thank you for this very useful tool.
I'm a newbie so sorry if my question is dumb.
I'd need to batch tag a large amount of files (+200000)
The actual list of files works great but is not ok for this purpose, too many entries. I have the paths in a text file, is there's a way Tag could read this text file's files adresses and tag the files?
Thanks in advance
I have some questions about how tags work in Mac OSx Finder. Are tags written to the file somehow, or is it stored somewhere else in the system? Can I see/edit the tags from other operating systems? My concern is if the tags will stick and be available in other environments.
Forgive me for asking through a github issue. I have not been able to find the answer for myself. I was looking to use a command line application like this to organize some media, but first I wanted to check the limitations of the work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.