na-- / ebook-tools

Shell scripts for organizing and managing ebook collections
GNU General Public License v3.0
726 stars 69 forks source link

Folder organizaiton options #9

Open nomandera opened 6 years ago

nomandera commented 6 years ago

Enhancement request. Allow for identified ebooks to be organized into a predictable folder structure without renaming the ebooks themselves.

My goal is to organize all books by Author but I can imagine others may want to organise by different metadata.

Note: I may need to also add sharding as filesystems like samba typically dont do well with multi-thousand long folder lists. Sharding may be off topic for this request but included for completeness.

Example for demonstration:

From:

Frank Herbert Dune.epub
Douglas Adams The Hitchhikers Guide to the Galaxy.epub
George Orwell Nineteen Eighty-Four.epub
Isaac Asimov Foundation.epub

To:

\organized-books\D\Douglas Adams The Hitchhikers Guide to the Galaxy.epub
\organized-books\F\Frank Herbert Dune.epub
\organized-books\G\George Orwell Nineteen Eighty-Four.epub
\organized-books\I\Isaac Asimov Foundation.epub

The drivers for this are:

Excellent work. Took me far to long to stumble uopn this excellent project idea.

na-- commented 6 years ago

There are several things here that I'll try to unpack :smile:, sorry if I don't address something.

Hopefully that covers everything :smile:. I'm happy that you like the scripts and I'll try to answer if you have any other questions or suggestions.

nomandera commented 6 years ago

Slowly but surely I have been learning how to get the best out of these tools. I currently have a very low successful match rate but I will raise my findings on another ticket as there is a reasonable chance this is PEBCAK.

In the interim your suggestions above work great and a big thanks for taking the time to help us all with this guide.

I have some relevant follow on's if it is ok

For context I am using this variant with the official docker:

organize-ebooks.sh \
    --keep-metadata \
    --organize-without-isbn \
    --output-folder=/organized-books/isbn \
    --output-folder-uncertain=/organized-books/uncertain \
    --output-folder-corrupt=/organized-books/corrupt \
    --output-filename-template='"${d[AUTHORS]:0:1}/${d[AUTHORS]}/${d[AUTHORS]} - ${d[TITLE]}${d[PUBLISHED]:+ (${d[PUBLISHED]%%-*})}.${d[EXT]}"' \
    /unorganized-books

Is there a way to use what Calibre refers to as Author sort

e.g. rather than Authors: C.L. Scholey we would use Author sort: Scholey, C.L.

I have still not found a way to maintain the original filename. I do not want to rename ebook files at all only organise them into folders based on their primary author. Is there a variable I can use that is the original unadulterated filename excluding path?

Finally to answer your question about metadata. As you can see I am currently using the --keep-metadata option but once I have ironed out all the bugs I will be dropping it. Why? A principle problem I have is filesyststem performance and caching as inode count increases. Doubling the number of files that are needed to be stored isnt viable for me. Perhaps OT but one central large metadata database would not be an issue, it is not a capacity issue just a file count one.

Thanks again

KeithPetro commented 5 years ago

As na-- mentioned, if your files are already named correctly as you want them (Author first), then you have no need to use these tools to sort them. A simple bash one-liner (as he provided in his post) works just fine:

for f in *; do dir="${f:0:1}"; mkdir -p "$dir"; mv "$f" "$dir/$f"; done

I would suggest that you use these tools as part of a workflow, rather than trying to view them as the be all end all of your tool kit.