Command-line tool to tag music?

What other productivity software are you working with...
binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Command-line tool to tag music?

Post by binocular222 »

I'm going to use XY to tag my music database (store the tag inside the music file), so:
- Which format (i.e ID3v1/ID3v2) allow XY's internal properties such as #mp3.genre ?
- Which command-line tool should I use?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

Currently, I use kid3 but just found out that XY's native properties only read ID3v1, ignore ID3v2.3
Hmn, why not support ID3v2?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Command-line tool to tag music?

Post by TheQwerty »

XY does support ID3v2.3 and sometimes 2.4.

Things have improved only slightly since I explored this last year:
screenshot.57.png
screenshot.57.png (41.67 KiB) Viewed 4591 times
Still XY claims Preview "cannot decode" MP3s with ID3v2.4 (at least here where I have no codecs installed).
There remain differences between the Meta tab and the columns:
v1.mp3; v1v2.4.mp3; and v2.4.mp3 only show Length & Bit rate in the Meta tab
v2.3.mp3 shows all fields (including comment) in the Meta tab but as you can see its MP3 Comments column is empty.

Maybe the inspiration that Don was waiting on is named binocular222? :lol:

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

Oh, that's, I'm testing on Comment field.
btw, why I cannot make XY scripting to work with kid3-cli.exe

Code: Select all

run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""select <curitem>"" -c ""set Comment abc"""
Maybe something wrong with quoting again? even running directly through cmd.exe not work

Code: Select all

kid3-cli.exe -c select "C:\test.mp3" -c set comment "abc"
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Re: Command-line tool to tag music?

Post by PeterH »

At least quoting of 1st box doesn't fit quoting of 2nd. (Multiple different parts inside inner quotes.)
And maybe a missing ';' at the end of 1st box?

Maybe us stepping mode, and have a look at the parameters of run.
(If it's a longer script: put a Step; in front of run.)
Win11 Pro 223H2 Gerrman

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

ok, found it

Code: Select all

	$term = "some genre";
	$command = "set genre '" . $term . "'";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""$command"" ""<curitem>"""
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Command-line tool to tag music?

Post by TheQwerty »

I was going to say. try:

Code: Select all

run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c 'select ""<curitem>""' -c 'set comment ""abc""'";
Their examples show that you are venturing into a land of quoting nightmares. :P

If you're able to use multi-line scripts I wholeheartedly recommend using heredocs:

Code: Select all

run <<<CMD
"D:\Doc\Temporary\kid3\kid3-cli.exe" -c 'select "<curitem>"' -c 'set comment "abc"'
CMD;

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Command-line tool to tag music?

Post by bdeshi »

I think this should've worked too

Code: Select all

::run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c 'select ""<curitem>""' -c 'set comment ""abc""'";

Code: Select all

::$itm = "I:\t e\m.ext"; $cmt = "bla blah"; run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c 'select ""$itm""' -c 'set comment ""$cmt""'";
I'm reasonably certain select, set, comment are builtin commands and shouldn't need to be in quotes.
ed. Okay, I stand corrected. :veryconfused:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Command-line tool to tag music?

Post by TheQwerty »

SammaySarkar wrote:I'm reasonably certain select, set, comment are builtin commands and shouldn't need to be in quotes.
Based solely on their examples I don't think that's the case. It looks like anytime the command passed to the '-c' option contains a space it is quoted - so while set and select are builtin commands because they contain more than just the command name the entire parameter specified to the '-c' option needs to be quoted.

For instance, look at this example:

Code: Select all

kid3-cli -c autoimport -c 'syncto 1' -c fromtag -c playlist \
  /path/to/dir/*.mp3
The syncto 1 is quoted because that particular command has additional arguments and thus contains a space.

EDIT: And then because some of these commands can contain their own arguments which can contain spaces (comments, file paths) those are also quoted.

So you've got multiple sets of quotes...
Those surrounding application and its arguments.
Those around some kid3 commands (passed to '-c').
Those around some parameters for the kid3 commands (passed to select, etc.).
:veryconfused:
/edit
SammaySarkar wrote:ed. Okay, I stand corrected. :veryconfused:
See a quoting nightmare! ;)

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

Oh, there seems to be a bug:
echo <prop #mp3.Comments>
trim off first 3 characters. i.e: ID3v2 comment "abcdef" → XY return "def"
This doesn't happens with ID3v1 comment
Last edited by binocular222 on 23 Mar 2015 14:10, edited 1 time in total.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Command-line tool to tag music?

Post by TheQwerty »

binocular222 wrote:Oh, there seems to be a bug:
echo <prop #mp3.Comments>
trim off first 3 characters. i.e: the comment "abcdef" → XY return "def"
That looks right to me.
What are you expecting?

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

echo <prop #mp3.Comments>
should return "abcdef"
Anyway, this seems to be a correct way to set comments via kid3-cli and also allow <prop #mp3.comments>

Code: Select all

	$term = "abyz ghi";
	$command = "set comment '" . $term . "'";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""tag 1"" -c ""$command"" ""<curitem>""";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""tag 2"" -c ""set comment ''"" ""<curitem>""";
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Command-line tool to tag music?

Post by TheQwerty »

binocular222 wrote:echo <prop #mp3.Comments>
should return "abcdef"
Anyway, this seems to be a correct way to set comments via kid3-cli and also allow <prop #mp3.comments>

Code: Select all

	$term = "abyz ghi";
	$command = "set comment '" . $term . "'";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""tag 1"" -c ""$command"" ""<curitem>""";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""tag 2"" -c ""set comment ''"" ""<curitem>""";
This goes back to the screenshot/post I mentioned earlier. I believe <prop #mp3.Comments> only pulls comments from the ID3v1 field, so if you only set the comment in ID3v2 XY won't see it.

I think you might be able to shorten that by doing:

Code: Select all

	$term = "abyz ghi";
	$command = "set comment '" . $term . "'";
	run """D:\Doc\Temporary\kid3\kid3-cli.exe"" -c ""tagformat 1"" -c ""tagformat 2"" -c ""$command"" ""<curitem>""";
Though I'd really recommend using:

Code: Select all

	$term = "abyz ghi";
	$command = <<<COMMAND
set comment "$term"
COMMAND;
	run <<<CMD
"D:\Doc\Temporary\kid3\kid3-cli.exe" -c 'tagformat 1' -c 'tagformat 2' -c '$command' "<curitem>"
CMD;

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Command-line tool to tag music?

Post by binocular222 »

ok, my plan is: Tag music with XY's native tag > copy that into music files' comment field > move files to another computer > copy comment filed to XY's native tag
Sound good? any better plan?

P.S maybe comment field is too volatile, I may use genre field instead
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Command-line tool to tag music?

Post by bdeshi »

write comments to a companion file/db. Eg,

Code: Select all

.\dir\file.mp3
.\dir\file2.mp3
.\dir.tags
.tags are text file that point to files as relative paths, and list tags/comments/labels/what have you, preferably in the same format as XY's tag.db.
The only requirement is the files have to be transferred without changing the relative path structure.

This will be faster and less cumbersome, and cleaner, than writing-reading each mp3 separately.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply