I'm on Linux and am writing a subroutine to change the ID tag of an mp3 file.
This command works: kid3-cli -c "tag 1" -c "set Title "TITLE"" -c "set Artist "ARTIST"" FILENAME.EXT
My attempt at trying this in ProcessBuilder:
new ProcessBuilder(Arrays.asList("kid3-cli", "-c", "\"tag", "1\"", "-c", "\"set", "Title", "\"" + title + "\"\"",
"-c", "\"set", "Artist", "\"" + artist + "\"\"", path.toString()))
I also thought to treat the quotes as a single parameter:
new ProcessBuilder(Arrays.asList("kid3-cli", "-c", "\"tag 1\"", "-c", "\"set Title \"" + title + "\"\"",
"-c", "\"set Artist \"" + artist + "\"\"", path.toString())
Whether or not it was successful can be verified with:
kid3-cli -c "get" SONG.EXT
When I run the program (with a few helpful debugging statements, I get:
INFO: COMMAND: kid3-cli -c "tag 1" -c "set Title "Unfinished Cathedral"" -c "set Artist "DAN TERMINUS"" /home/sarah/Music/Indexing/Temp/DAN TERMINUS - Unfinished Cathedral.mp3
And the tags come up as:
(base) sarah@MidnightStarSign:~/Music/Indexing/Temp$ kid3-cli -c "get" DAN\ TERMINUS\ -\ Unfinished\ Cathedral.mp3
File: MPEG 1 Layer 3 128 kbps 44100 Hz Joint Stereo 4:38
Name: DAN TERMINUS - Unfinished Cathedral.mp3
Tag 2: ID3v2.3.0
Title
Artist
Album
Comment Visit http://dan-terminus.bandcamp.com
Date 2014
Track Number 9
Album Artist DAN TERMINUS
Picture: Cover (front) cover
I'm fairly certain that I'm doing something wrong with regards to the number of entries to give the processbuilder, but I'm not sure. How can I get it to behave properly?
EDIT 0:
Strangely enough,. this also fails (although it has the exact same output when the command is queried, and if run on bash, will change the tags):
new ProcessBuilder(Arrays.asList("bash", "-c", "\"kid3-cli -c \"tag 1\" -c \"set Title \"" + title + "\"\" -c \"set Artist \""
+ artist + "\"\"" + path.toString() + "\"");
Although it leads to the correct string: INFO: COMMAND: bash -c "kid3-cli -c "tag 1" -c "set Title "Unfinished Cathedral"" -c "set Artist "DAN TERMINUS""/home/sarah/Music/Indexing/Temp/DAN TERMINUS - Unfinished Cathedral.mp3"