Get destination filenames when importing

I’d like to be able to import a directory full of files (singletons, from different albums) and be informed where each file ended up in my library directory, so that I can make a playlist with those tracks. Is there already a way to get beet import -s to provide that information? (I don’t think so but I’m a n00b so am still overlooking obvious things.)

It also seems like it’d be straightforward to write a plugin to do this (say, set a listener for item_imported and have it call item.destination()), so that’d be my default plan of attack.

Hi! Maybe try the --set option to the import command, which lets you set a flexible attribute on all the things that were imported? For example, beet impost -s --set batch=playlist1 ./dir would mark them so you can later find all the items with beet ls batch:playlist1. Or add -p to that latter command to get a list of paths.

This works for my use case - thanks! I think I can make a little script which will pick a tag based on the time, e.g.

#!/usr/bin/env sh
tag=$(date +%Y%m%d_%k%M%S)
beet import -s --set batch=$tag "$@"
beet ls batch:$tag -p

As an aside, the same procedure doesn’t seem to work for an album import (e.g. beet import --set batch=playlist1 ./album_dir). I can still see the expected tag in the batch field with e.g. beet list -f '$artist:$album - $title, $batch' foo, but beet list batch:playlist1 doesn’t give any results.

You’ll want to use the -a flag to the beet ls command to list albums instead of items.

1 Like

This is a nice solution, but how would one go about deleting the attributes after querying the db with beet ls ? That way we could use batch=playlist1 as a temp playlist to get a list of path for one album only and not add to it for each import .

beet modify can delete attributes using !.

working perfectly, thank you :+1: