You can use this script to organize your books into directories based on tags
https://pastebin.com/tPGTcjYc. You need to modify *hierarchy* variable to fit your liking, create new "Column build from columns" in calibre. Enter the resulting "program" from the script into the "Template" field (of the custom column). When you connect your device to calibre click "Configure this device" -> Save Template -> {#lookup name} of your column.
You can see more on how it works and what it does in.
https://manual.calibre-ebook.com/tem...custom-columns
https://manual.calibre-ebook.com/tem...l-program-mode