How do I automatically create a subdirectory on moving/importing an album?

I keep album covers and other non-track metadata in a meta/ directory under each album directory to segregate them from actual music tracks. Currently, whenever I import new music I need to:

  • Import the music once
  • Create the meta directories,
  • Rerun beets to fetch any album art

with a similar process needed whenever I move files. Is there any way to get beets to create these meta directories automatically before moving/importing files?

A straightforward hack could be to use the hook plugin:

You could listen to the album_imported event and use something like mkdir os.path.join(album.path, 'meta')? That idea probably needs some tweaking, but it could be the right direction.

1 Like

Solved it with a hook and a few scripts in the end,

Hook config

    # create meta directory before an item is moved
    - event: before_item_moved
      command: "{destination}"

    # move items from meta directories
    - event: before_item_moved
      command: "{source}" "{destination}"

MDIR="$(dirname "$FPATH")/meta"
mkdir -p "$MDIR"

SMDIR="$(dirname "$SPATH")/meta"
DMDIR="$(dirname "$DPATH")/meta"
if [ "$SMDIR" != "$DMDIR" ] && [ -e "$SMDIR" ]; then
   if [ "$(ls -A "$SMDIR")" ]; then
    mv -v "${SMDIR}"/* "${DMDIR}/"
   rmdir "${SMDIR}"