sandreas / m4b-tool

m4b-tool is a command line utility to merge, split and chapterize audiobook files such as mp3, ogg, flac, m4a or m4b
MIT License
1.15k stars 76 forks source link

Having images or text files in an intermediate directory for batch processing can lead to unexpected results #259

Open StefanLobbenmeier opened 4 months ago

StefanLobbenmeier commented 4 months ago

Just spent some time debugging why the readme did not work for me, wanted to share what was wrong with my setup so it does not happen to others.

My folder structure was about like this: input/Fantasy/J.K. Rowling/Harry Potter/5/Harry Potter and the Order of the Phoenix/Chapter 33 - Fight and Flight.mp3

The issue was, I also had some general thumbnails in input/Fantasy/J.K. Rowling/Harry Potter

The code here looks for text and image files and stops looking for deeper folders once it found them: https://github.com/sandreas/m4b-tool/blob/02142f6d649777d53784ec46f3391d2722ba1e3f/src/library/Command/MergeCommand.php#L257-L260

That meant that the matching like this --batch-pattern="input/%g/%a/%s/%p/%n/ no longer worked, because it is unable to match %p/%n/

Does not necessarily need a fix, but maybe we can add this to the README that when creating the folder structure the directory tree should but completely free of files to avoid this from happening. As a workaround I renamed my .png and .txt files to .png.hide and .txt.hide and that also works 😄

sandreas commented 4 months ago

Yeah sometimes m4b-tool tries to hard to be convenient :-) Probably my fault because I follow an absolutely strict file structure for my personal library.

Maybe you could try the command with

--batch-pattern-path="input/"

that might fix the problem, but this is only available in the latest pre-release.

The documentation update is something I defintely consider, regardless --batch-pattern-path works or not.

Thanks for reporting.