# Variable path for singletons based on band presence in album folder

**URL:** <https://discourse.beets.io/t/variable-path-for-singletons-based-on-band-presence-in-album-folder/143>\
**Category:** Help\
**Created:** [August 1, 2017, 10:47am UTC](https://discourse.beets.io/t/variable-path-for-singletons-based-on-band-presence-in-album-folder/143 "2017-08-01T10:47:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterbelmans](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/peterbelmans/32/53_2.png) [@peterbelmans](https://discourse.beets.io/u/peterbelmans)\
**Post date:** [August 1, 2017, 10:47am UTC](https://discourse.beets.io/t/variable-path-for-singletons-based-on-band-presence-in-album-folder/143/1 "2017-08-01T10:47:01Z")

</div>

Hi, I have two music folders:

- Albums
- Non-Album

I would like to have each band to be just once in one of these folders.  
Is it possible to have the importer in singleton mode check if the band is already present in albums, and if so, change the path for that music file?

In code (for config.yaml or elsewhere) should be something like:  
#In singleton mode:  
#If $artist IN Muziek\_Album/$albumartist THEN singleton: Muziek\_Album/$artist/#Non-album/$title  
paths:  
default: Muziek\_Album/$albumartist/$album%aunique{}/$track $title  
singleton: Muziek\_Non-Album/$artist/$title  
comp: Muziek\_Album/#Compilations/$album%aunique{}/$track $title

Then f.e. I would have:  
AC\_DC/#Non-album  
AC\_DC/Powerage  
AC\_DC/Black Ice

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [August 1, 2017, 2:00pm UTC](https://discourse.beets.io/t/variable-path-for-singletons-based-on-band-presence-in-album-folder/143/2 "2017-08-01T14:00:35Z")

</div>

Something like this will require a bit of hackery—checking the filesystem to determine a path won’t be accomplishable without it. Specifically, you will need to either create a custom plugin or use the `inline` plugin, which lets you use Python code to define new fields. In either case, you can `import os.path` and use that to check whether a given directory exists, or you can issue queries back to the beets database to see if there are albums with a given artist. To do the latter, the code will look something like `lib.albums(dbcore.query.MatchQuery(‘albumartist’, some_artist))`.

---

<div class="post-metadata">

**Author:** ![peterbelmans](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/peterbelmans/32/53_2.png) [@peterbelmans](https://discourse.beets.io/u/peterbelmans)\
**Post date:** [August 1, 2017, 7:31pm UTC](https://discourse.beets.io/t/variable-path-for-singletons-based-on-band-presence-in-album-folder/143/3 "2017-08-01T19:31:19Z")

</div>

Adrian, thanks for your response, I will try to get started with your information.  
I’m quite new to Linux but I like programming so i’m happy to spend some time on it.

If I find the solution I will post it here!
