audiobookshelf icon indicating copy to clipboard operation
audiobookshelf copied to clipboard

Added functionality to rename book folders.

Open yuuzhan opened this issue 2 years ago • 20 comments

Added a defaultRenameFormat setting on the server. This item is returned when fetching server settings to be displayed by clients and updated as appropriate. Two api endpoints added:

/api/tools/item/[ID]/renameFolder?includeSampleTemplate=1&strFormat=$bookName. includeSampleTemplate(optional) will return a object with each supported format string, and what it would process to for the existing entity.

the GET method for the above endpoint will just return what would happen if you did rename, without actually altering anything. the POST of the method will execute the rename. Logic exists to check if target folder exists, or is a subfolder of another book. Will fail gracefully if so.

Added client code to interact with the above endpoints.

image image image

yuuzhan avatar Feb 20 '23 15:02 yuuzhan

Is it possible to move items from one directory to another?

For example I currently use /audiobooks/temp and /audiobooks/clean. Could this tool move from one to the other, or can it only change the immediate directory?

hobesman avatar Feb 20 '23 15:02 hobesman

Is it possible to move items from one directory to another?

For example I currently use /audiobooks/temp and /audiobooks/clean. Could this tool move from one to the other, or can it only change the immediate directory?

Yes and no. Copying answer from discord:

If your setup is like this, then no. The process will not move a book to a new parent folder: image

If your setup is like this then yes you can, as they are all subfolders of the single parent folder: image

yuuzhan avatar Feb 20 '23 16:02 yuuzhan

@advplyr Is there any chance this will be merged in the near future? I very much need something to clean up my folder structure. I starting writing code using the API but then realized the API doesn't provide the means of changing the storage path which means I'd have to look at hitting the DB directly which makes me cringe somewhat.

portrman avatar Nov 12 '23 05:11 portrman

This would be a great addition. Any chance for it being approved?

austinsr1 avatar Dec 16 '23 00:12 austinsr1

I agree, it would be a great addition, been subscribed for some time now waiting to see if it will be approved, any updated on it's status would be appreciated!

JamesDean3 avatar Dec 17 '23 02:12 JamesDean3

That feature would make this project for incredible to Perfect! I too would need something like that for my folder structure

Ansem93 avatar Jan 23 '24 00:01 Ansem93

Would love this!!! I was going to set up readarr to accomplish the same thing, but it doesn't integrate with Audiobookshelf metadata.

Please please please :)

ameeno avatar Jan 23 '24 13:01 ameeno

I'm going to hop in and say I agree with those above. I haven't yet found a good way to keep my library organized (Reader and LazyLibrarian have their issues), and so this would be a great step in that goal.

So please give us an update when you have time, even if it's to let us know why you're not accepting this PR, and the steps needed to make it acceptable.

Regardless, Thanks for the great work!

MadDogTen avatar Jan 23 '24 14:01 MadDogTen

Whether reorganizing files should be a part of the core ABS functionality or left to external scripts/plugins/tools is still up in the air.

nichwall avatar Jan 23 '24 14:01 nichwall

Possibly nothing advanced, but some basic moving/renaming would still be great if you modify some metadata or need to change your directory structure.

mastafrooper avatar Jan 24 '24 09:01 mastafrooper

The issue is that if an external tool is used for moving files, it must also transfer all the metadata and image files. Additionally, it should read the metadata file to understand the desired folder structure. Then, you'll need to resync the Audiobookshelf library and hope it detects the changes, instead of causing errors with the books.

It would be more efficient if ABS managed the renaming and library updates in a single action.

ameeno avatar Jan 24 '24 10:01 ameeno

The issue is that if an external tool is used for moving files, it must also transfer all the metadata and image files. Additionally, it should read the metadata file to understand the desired folder structure. Then, you'll need to resync the Audiobookshelf library and hope it detects the changes, instead of causing errors with the books.

It would be more efficient if ABS managed the renaming and library updates in a single action.

It has been a long time since I wrote this, but as I recall I move the files using the system move function, but also update the audiobook shelf of the new location so no re-scan is needed.

I have also done a move, then done a clean import of the moved files and as long as the metadata file is written in the folder, ABS loads that data and imports successfully. I didn't do many tests if the file was not written IIRC, but it was a long time ago :P

I have chatted with the author about the change in discord and he seems to like the idea, but isint sure when he is going to tackle the change - i dont think his plan is to import this PR but re-code it in his own style (but I could be wrong)

yuuzhan avatar Jan 24 '24 16:01 yuuzhan

Are there any updates regarding the 'new' implementation or accepting this PR ? I would REALLY like this feature being added.

If there are things missing, let me know and i can probably contribute as well.

MarcoMue avatar May 04 '24 19:05 MarcoMue

@advplyr Any chance of an update or potential merge?

iAmZyk avatar May 28 '24 04:05 iAmZyk

I have created a basic terminal utility that can help create a new directory structure based on the metadata.json file, until a more permanent solution can be rolled into the application or some official utility to do it. It doesn't actually move the files itself but generates the bash to do so. https://github.com/austinsr1/ab_mover/

austinsr1 avatar Jun 04 '24 20:06 austinsr1

I have created a basic terminal utility that can help create a new directory structure based on the metadata.json file, until a more permanent solution can be rolled into the application or some official utility to do it. It doesn't actually move the files itself but generates the bash to do so. https://github.com/austinsr1/ab_mover/

Looks great - thanks for the effort! Only thing it does not do well is handle in-between books. Books with the number of e.g. 2.5 get put as book 2. Example:

mv '/Path/Example Author/ Example Book 2.50'/* '/Path/Example Author/Example Series/Book 2/'

Elsu avatar Jun 08 '24 02:06 Elsu

Thanks for the bug report! Its been fixed on github.

On Fri, Jun 7, 2024 at 10:51 PM Elsu @.***> wrote:

I have created a basic terminal utility that can help create a new directory structure based on the metadata.json file, until a more permanent solution can be rolled into the application or some official utility to do it. It doesn't actually move the files itself but generates the bash to do so. https://github.com/austinsr1/ab_mover/

Looks great - thanks for the effort! Only thing it does not do well is handle in-between books. Books with the number of e.g. 2.5 get put as book 2. Example:

mv '/Path/Example Author/ Example Book 2.50'/* '/Path/Example Author/Example Series/Book 2/'

— Reply to this email directly, view it on GitHub https://github.com/advplyr/audiobookshelf/pull/1521#issuecomment-2155776490, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXQP63M76V2OOVEC52QQ5G3ZGJWUPAVCNFSM6AAAAAAVCA4LVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNJVG43TMNBZGA . You are receiving this because you commented.Message ID: @.***>

austinsr1 avatar Jun 09 '24 16:06 austinsr1

Thanks for the bug report! Its been fixed on github.

Thanks mate. Sent you a suggestion for avoding listing already aligned files.

Another issue I found is that ' in e.g. the authors name breaks it script. Have not tested whether there are any more.

Elsu avatar Jun 09 '24 23:06 Elsu

The issue is that if an external tool is used for moving files, it must also transfer all the metadata and image files. Additionally, it should read the metadata file to understand the desired folder structure. Then, you'll need to resync the Audiobookshelf library and hope it detects the changes, instead of causing errors with the books. It would be more efficient if ABS managed the renaming and library updates in a single action.

It has been a long time since I wrote this, but as I recall I move the files using the system move function, but also update the audiobook shelf of the new location so no re-scan is needed.

I have also done a move, then done a clean import of the moved files and as long as the metadata file is written in the folder, ABS loads that data and imports successfully. I didn't do many tests if the file was not written IIRC, but it was a long time ago :P

I have chatted with the author about the change in discord and he seems to like the idea, but isint sure when he is going to tackle the change - i dont think his plan is to import this PR but re-code it in his own style (but I could be wrong)

Could you bring this topic up again ?

MarcoMue avatar Aug 06 '24 16:08 MarcoMue

This is one of the features I'm missing. Been doing this with Mp3Tag for my Plex audiobook library.

pax0707 avatar Aug 21 '24 22:08 pax0707