sandreas / tone

tone is a cross platform audio tagger and metadata editor to dump and modify metadata for a wide variety of formats, including mp3, m4b, flac and more. It has no dependencies and can be downloaded as single binary for Windows, macOS, Linux and other common platforms.
https://pilabor.com
Apache License 2.0
410 stars 17 forks source link

Could not find file with double quote in name and folder #43

Closed SenorSmartyPants closed 1 year ago

SenorSmartyPants commented 1 year ago

Filename: /audiobooks/Scott Frost/"Diane..." The Twin Peaks Tapes of Agent Cooper/"Diane..." The Twin Peaks Tapes of Agent Cooper.m4b

If I try this in the directory tone dump \"Diane...\"\ The\ Twin\ Peaks\ Tapes\ of\ Agent\ Cooper.m4b I get the error Error: Could not find file '/audiobooks/Scott Frost/"Diane..." The Twin Peaks Tapes of Agent Cooper/Diane...'.

If I rename the file to test.m4b tone dump generates output.

Version 0.1.2 bundled with AudiobookShelf

sandreas commented 1 year ago
$ /tmp/"Diane..." The Twin Peaks Tapes of Agent Cooper
> tone dump --format=json '"Diane..." The Twin Peaks Tapes of Agent Cooper.m4b' --query="$.meta.genre"
Fantasy

Works for me... it could either be an escaping issue or maybe if you are on Windows, it may be that there is some other issue.

SenorSmartyPants commented 1 year ago

Running in an ARM64 docker container of audiobookshelf. Did it work for you with version 0.1.2? I haven't been able to test with a newer version yet.

I tried your same command line using single quote escapes and it doesn't work. I also noticed in the error message it doesn't print the full filename, truncates after Diane.... Also note there are no quotes around that Diane.

sandreas commented 1 year ago

Aah haha, now I know what is happening. I did some research and found out what's the problem...

There was a problem in spectre.console, the command line library, which led to issues with parsing command line arguments with quotes (see https://github.com/spectreconsole/spectre.console/issues/891). It was fixed by Sir Awesome himself @FrankRay78, but first shipped with 0.1.3, so version 0.1.2 still has this bug and it affects you.

As a workaround you could prevent " being the first char of your filename argument like this:

 tone dump './"Diane..." The Twin Peaks Tapes of Agent Cooper.m4b'

which also works with 0.1.2, while I would strongly recommend to upgrade tone to the latest release wherever possible (I know it's not your own docker image). These command line parsing bugs where really nasty and while I was not taken serious for a long time by the maintainers, this can lead to data loss when tagging files.

I'll close this, since it is fixed in the latest release and I hope this explanation did help you.

Thank you for your patience.