# Original\_year in folder name if different than year

**URL:** <https://discourse.beets.io/t/original-year-in-folder-name-if-different-than-year/1743>\
**Category:** Help\
**Created:** [April 6, 2021, 12:35pm UTC](https://discourse.beets.io/t/original-year-in-folder-name-if-different-than-year/1743 "2021-04-06T12:35:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![touz](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@touz](https://discourse.beets.io/u/touz)\
**Post date:** [April 6, 2021, 12:35pm UTC](https://discourse.beets.io/t/original-year-in-folder-name-if-different-than-year/1743/1 "2021-04-06T12:35:53Z")

</div>

Hello there, I’ve recently started using beets and I like it very much. I got my config file almost like I’d like it to be except for a small detail. I’d like to write the $original\_year to the folder name if it’s different than $year. I guess it would be possible to substract $original\_year-$year in Python with the inline plugin, but I don’t know anything about Python. Would someone be able to assist me with this?

Here’s my current config file:

> Blockquote  
> plugins: fetchart embedart convert scrub replaygain lastgenre chroma web extrafiles inline discogs mbsync  
> directory: /music  
> library: /config/musiclibrary.blb  
> art\_filename: cover  
> threaded: yes  
> original\_date: no  
> #artist\_credit: yes  
> per\_disc\_numbering: true

convert:  
auto: no  
ffmpeg: /usr/bin/ffmpeg  
opts: -ab 320k -ac 2 -ar 48000  
max\_bitrate: 320  
threads: 4  
never\_convert\_lossy\_files: yes

extrafiles:  
patterns:  
artworkdir:  
- ‘[sS]cans/’  
- ‘[sS]can/’  
- ‘[aA]rtwork/’  
- ‘[aA]rtworks/’  
- ‘[aA]rt/’  
- ‘[cC]overs/’  
- ‘[cC]over/’  
artworkfiles:  
- ‘_.png’  
- '_/_.png’  
- '_.jpg’  
- ‘_/_.jpg’  
- ‘_.jpeg’  
- '_/_.jpeg’  
- '_.gif’  
- ‘_/_.gif’  
- ‘_.pdf’  
- '_/_.pdf’  
datafiles:  
- '_.log’  
- ‘_/_.log’  
- ‘_.txt’  
- '_/_.txt’  
- '_.md5’  
- ‘_/_.md5’  
- ‘_.ffp’  
- '_/_.ffp’  
- '_.cue’  
- ‘_/_.cue’  
- ‘_.CUE’  
- '_/_.CUE’  
- '_.nfo’  
- ‘_/_.nfo’  
- ‘_.st5’  
- '_/_.st5’  
- '_.yaml’  
- ‘_/_.yaml’

```
paths:
    artworkdir: $albumpath/artwork
    artworkfiles: $albumpath/artwork/$filename
    datafiles: $albumpath/data/$filename

```

#discogs:

# source\_weight: 0.0

match:  
preferred:  
media: [‘CD’,‘Digital Media|File’]  
#original\_year: yes  
#countries: [‘US’]

item\_fields:  
disc\_and\_track: u’%2i%02i’ % (disc, track) if disctotal \> 1 else u’%02i’ % (track)  
disc\_1\_char: u’%2i’ % (disc)  
multidisc: 1 if disctotal \> 1 else 0  
#v\_year: 0 if release\_year = year else 1

album\_fields:  
mediatype: |  
mediaList = {  
‘12" Vinyl’: “Vinyl”,  
‘7" Vinyl’: “Vinyl”,  
“Digital Media”: “WEB”,  
“File”: “WEB”,  
“Enhanced CD”: “CD”,  
“CD-R”: “CD”,  
“CDr”: “CD”,  
}  
try:  
return mediaList[items[0].media]  
except KeyError:  
return items[0].media  
bitdepthmost: |  
bitdepths = dict()  
for item in items:  
try:  
bitdepths[item.bitdepth] += 1  
except KeyError:  
bitdepths[item.bitdepth] = 1  
sorted\_depths = {k: v for k, v in sorted(bitdepths.items(), key=lambda item: item[1])}  
return list(sorted\_depths)[-1]  
sampleratemost: |  
samplerates = dict()  
for item in items:  
try:  
samplerates[item.samplerate] += 1  
except KeyError:  
samplerates[item.samplerate] = 1  
sorted\_rates = {k: v for k, v in sorted(samplerates.items(), key=lambda item: item[1])}  
formatted\_num = int(list(sorted\_rates)[-1]/1000) if int(list(sorted\_rates)[-1]/1000) == float(list(sorted\_rates)[-1]/1000) else float(list(sorted\_rates)[-1]/1000)  
return str(formatted\_num) + “kHz”  
#bettercatalognum: |  
# return items[0].catalognum if items[0].catalognum != “[none]” else “”  
mp3\_quality: |  
if items[0].format.upper() == “MP3”:  
total\_bitrate = 0  
for item in items:  
total\_bitrate += item.bitrate  
average\_bitrate = total\_bitrate / len(items) / 1000  
if average\_bitrate == 320:  
return “320”  
elif average\_bitrate == 192:  
return “192”  
elif average\_bitrate == 160:  
return “160”  
elif average\_bitrate == 128:  
return “128”  
elif average\_bitrate \>= 200:  
return “V0”  
else:  
return “TOO LOW FIND NEW SOURCE”  
else:  
return items[0].format  
cd\_no\_bitrate\_and\_khz: |  
if items[0].media.upper() == “CD”:  
return 0  
else:  
return 1

paths:  
#default: $albumartist/Gitara (1997) [WEB-FLAC] {2011$}/%if{$multidisc,disc$disc\_1\_char/}$track. $title  
default: $albumartist/$album %if{$original\_year,($original\_year)} [%if{$mediatype,$mediatype-}$format] %if{$cd\_no\_bitrate\_and\_khz,{%if{$bitdepth,$bitdepthmost,$mp3\_quality}-$sampleratemost$}} %if{$albumdisambig,{$year $albumdisambig$}}/%if{$multidisc,disc$disc\_1\_char/}$track. $title  
#default: $albumartist/$album %if{$year,($year)} [%if{$mediatype,$mediatype-}$format] %if{$cd\_no\_bitrate\_and\_khz,{%if{$bitdepth,$bitdepthmost,$mp3\_quality}-$sampleratemost$}} %if{$albumdisambig,{$albumdisambig$}}/%if{$multidisc,disc$disc\_1\_char/}$track. $title  
singleton: Non-Album/$artist - $title  
#comp: Compilations/$album %if{$year,($year)} [%if{$mediatype,$mediatype-}$format] %if{$cd\_no\_bitrate\_and\_khz,{%if{$bitdepth,$bitdepthmost,$mp3\_quality}-$sampleratemost$}} %if{$albumdisambig,{$$albumdisambig$}}/%if{$multidisc,disc$disc\_1\_char/}$track. $artist - $title  
comp: Compilations/$album %if{$original\_year,($original\_year)} [%if{$mediatype,$mediatype-}$format] %if{$cd\_no\_bitrate\_and\_khz,{%if{$bitdepth,$bitdepthmost,$mp3\_quality}-$sampleratemost$}} %if{$albumdisambig,{$year $albumdisambig$}}/%if{$multidisc,disc$disc\_1\_char/}$track. $artist - $title  
#comp: Compilations/$album%aunique{}/$disc$track. $title  
albumtype\_soundtrack: Soundtracks/$album %if{$original\_year,($original\_year)} [%if{$mediatype,$mediatype-}$format] %if{$cd\_no\_bitrate\_and\_khz,{%if{$bitdepth,$bitdepthmost,$mp3\_quality}-$sampleratemost$}} %if{$albumdisambig,{$year $albumdisambig$}}/%if{$multidisc,disc$disc\_1\_char/}$track. $artist - $title

import:  
write: yes  
copy: yes  
move: no  
resume: ask  
#incremental: yes  
incremental: no  
quiet\_fallback: skip  
timid: yes  
log: /config/beet.log

lastgenre:  
auto: yes  
source: album  
force: yes  
count: 1  
min\_weight: 10  
canonical: yes  
#fallback: ‘Acoustic’  
#whitelist: /config/genres.txt

embedart:  
auto: yes

fetchart:  
auto: yes

replaygain:  
backend: gstreamer  
auto: yes

scrub:  
auto: yes

replace:  
‘^.’: \_  
‘[\x00-\x1f]’: \_  
‘[\<\>:"?\*|]’: \_  
‘[\xE8-\xEB]’: e  
‘[\xEC-\xEF]’: i  
‘[\xE2-\xE6]’: a  
‘[\xF2-\xF6]’: o  
‘[\xF8]’: o  
‘.$’: \_  
‘\s+$’: ‘’  
web:  
host: 0.0.0.0  
port: 8337

Thanks a lot!

---

<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:** [April 6, 2021, 7:49pm UTC](https://discourse.beets.io/t/original-year-in-folder-name-if-different-than-year/1743/2 "2021-04-06T19:49:45Z")

</div>

Hi! I think you’re on the right track with this commented-out `inline` plugin declaration:

```auto
v_year: 0 if release_year = year else 1

```

…but you’ll need to be careful to get the field names right (e.g., `original_year`). You can debug this by running a command like:

```auto
beet ls -f '$artist - $title - $v_year`

```

…and then attempt to use this in an `%if` context next:

```auto
beet ls -f '$artist - $title - %if{$v_year,$original_year - $year,$year}`

```

or similar.

---

<div class="post-metadata">

**Author:** ![touz](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@touz](https://discourse.beets.io/u/touz)\
**Post date:** [April 16, 2021, 7:30pm UTC](https://discourse.beets.io/t/original-year-in-folder-name-if-different-than-year/1743/3 "2021-04-16T19:30:39Z")

</div>

thank you for your help, I was finally able to test it again. Because of your comment, I saw that I was using the release\_year field instead of original\_year. It’s now working!!  
So, for anyone looking to do the same thing, here’s how I made it work:

> item\_fields:  
> disc\_and\_track: u’%2i%02i’ % (disc, track) if disctotal \> 1 else u’%02i’ % (track)  
> disc\_1\_char: u’%2i’ % (disc)  
> multidisc: 1 if disctotal \> 1 else 0  
> v\_year\_diff: 0 if original\_year == year else 1

> ```
> default: $albumartist/$album%if{$original_year, ($original_year)} [%if{$mediatype,$mediatype-}$format] %if{$cd_no_bitrate_and_khz,{%if{$bitdepth,$bitdepthmost,$mp3_quality}-$sampleratemost$}%if{$v_year_diff,%if{$albumdisambig, {$year $albumdisambig$}, ($year)},%if{$albumdisambig, {$albumdisambig$}}},%if{$v_year_diff,%if{$albumdisambig,{$year $albumdisambig$},($year)},%if{$albumdisambig,{$albumdisambig$}}}}/%if{$multidisc,disc$disc_1_char/}$track. $title
> 
> ```
