# Track genre as variable in path

**URL:** <https://discourse.beets.io/t/track-genre-as-variable-in-path/1012>\
**Category:** Help\
**Created:** [November 25, 2019, 11:58pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012 "2019-11-25T23:58:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drubio](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/drubio/32/321_2.png) [@drubio](https://discourse.beets.io/u/drubio)\
**Post date:** [November 25, 2019, 11:58pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/1 "2019-11-25T23:58:14Z")

</div>

Hi!  
im a new user of beets and i don’t know if this is already a feature or not. and i love it btw.  
I need to use the genre of the tracks in the paths but the variable $genres only refers to the album genre and there is not a variable for the track genre.  
this is tricky becouse with this config:

> default: $genre/$albumartist/$album%aunique{}/$track $title

i have tracks with House genre in the “Deep House” folder.  
Maybe im using it wrong.  
There is a way to use the track genre or a way to access it ?

---

<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:** [November 26, 2019, 2:12pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/2 "2019-11-26T14:12:04Z")

</div>

Good question—this is a little tricky because, in general, it’s hard to disambiguate track-level information from album-level information of the same name.

One thing you might try is to use the `inline` plugin. Define a new track-level field that just remaps `genre` to a new name:

```auto
item_fields:
    track_genre: genre

```

Then use `$track_genre` in your path formats. I think this should probably work?

---

<div class="post-metadata">

**Author:** ![drubio](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/drubio/32/321_2.png) [@drubio](https://discourse.beets.io/u/drubio)\
**Post date:** [November 26, 2019, 3:55pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/3 "2019-11-26T15:55:26Z")

</div>

Works perfectly!  
Thanks adrian!

---

<div class="post-metadata">

**Author:** ![kergoth](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kergoth/32/240_2.png) [@kergoth](https://discourse.beets.io/u/kergoth)\
**Post date:** [November 27, 2019, 3:28pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/4 "2019-11-27T15:28:27Z")

</div>

This seems odd, aren’t path formats evaluated against the item? I’d expect it to prefer the item field and fall back to the album, not the other way around, unless used in the `format_album` format.

---

<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:** [November 27, 2019, 3:54pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/5 "2019-11-27T15:54:42Z")

</div>

There is actually a special formatting mode for paths that makes album-level information take precedence:

> <https://github.com/beetbox/beets/blob/1b187fbf5345727e0dfdaea958a714f19e917a4e/beets/library.py#L374>

This is important because most people include album-level fields in their paths _when they want to group albums together_. So a path like `$genre/$artist/$album` would, by default, get “broken up” into different directories if the `$genre` field differed across items. Preferring album-level data keeps things coalesced together as much as possible.

---

<div class="post-metadata">

**Author:** ![kergoth](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kergoth/32/240_2.png) [@kergoth](https://discourse.beets.io/u/kergoth)\
**Post date:** [November 27, 2019, 4:07pm UTC](https://discourse.beets.io/t/track-genre-as-variable-in-path/1012/6 "2019-11-27T16:07:41Z")

</div>

Ah! Thanks, that clarifies it. Not sure how I missed that one.
