# Multi disc album folder renaming action-different levels

**URL:** https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834
**Category:** Support
**Created:** [February 3, 2021, 10:21am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834 "2021-02-03T10:21:06Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![usavaci](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@usavaci](https://community.mp3tag.de/u/usavaci)
#### Post date: [February 3, 2021, 10:21am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/1 "2021-02-03T10:21:06Z")

</div>

I have created an action for renaming folders based on extension.

With this code, if extension is flac it will add bitspersample and sample rate to the folder name otherwise it add the extension like MP3 or ALAC.

`%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'),"("$upper(%_extension%)")" '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')`

I have found that this code become not so useful for multi disc albums because of the different folder structures.

I am using a folder structure like below.  
(level4) (level3)\ Level2 \Level1  
mymusic\FLAC\Artist-year-Album\CD1  
mymusic\FLAC\Artist-year-Album\CD2

In that folder structure above code only changes names of the CD1 and CD2 folders not Artist-year-Album this folder like below.

> mymusic\FLAC\Artist-year-Album\CD1 [bitspersample-samplerate]  
> mymusic\FLAC\Artist-year-Album\CD2 [bitspersample-samplerate]

What I want to do is rename multi disc folders given below

> mymusic\FLAC\Artist-year-Album [bitspersample-samplerate]\CD1  
> mymusic\FLAC\Artist-year-Album [bitspersample-samplerate]\CD2

First of all is there any way to change name of the Artist-year-Album folder given above with an action ? if yes than an if condition might be a solution for that like  
if total disc is equal and greater than 2 change the name of level 2 folder otherwise change the name of level 1 etc.

whenever I run this code it create new %ARTIST%'-'%YEAR%'-'%ALBUM% folders then CD2 folders.

$ifgreater(%discnumber%,1,_**%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')\CD%discnumber%**_,_%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')_)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 3, 2021, 10:30am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/2 "2021-02-03T10:30:52Z")

</div>

I would use an absolute path and not a relative one and add the CD part in square brackets, so that this level only is inserted if the discnumber is filled.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 3, 2021, 10:56am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/3 "2021-02-03T10:56:35Z")

</div>

You just have to move your part in square brackets `'['%_bitspersample%'-'$cutRight(%_samplerate%,3)']'` to your "Level2".  
This means BEFORE your `\CD%discnumber%...` part.

I would do it with two actions:  
One for the single disc albums  
One for the multi disc albums

---

<div class="post-metadata">

### Author: ![usavaci](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@usavaci](https://community.mp3tag.de/u/usavaci)
#### Post date: [February 3, 2021, 11:27am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/4 "2021-02-03T11:27:04Z")

</div>

'['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']' this part is actually before the \CD%discnumber%

_**%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')**_

with this code first it checks whether it is FLAC or not and if it is flac then add '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']' information. if it is not flac then add the extension. I made a mistake in copy/paste in my first post. I am using the below version and works like a charm in single disc albums.

**%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),'['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')**

@LyricsLover is that what you mean or can you modify the code please. For your suggestion about the two seperate actions, how can it be done ? could you please explain little bit.

@ohrenkino How absolute path can be implemented to the code, I have no experience. Could you pelase explain a little bit.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 3, 2021, 11:31am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/5 "2021-02-03T11:31:09Z")

</div>

> [@usavaci](#):
>
> mymusic\FLAC\Artist-year-Album\CD1

Use something like  
`d:\mymusic\FLAC\Artist-year-Album[\CD1]`

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [February 3, 2021, 11:54am UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/6 "2021-02-03T11:54:59Z")

</div>

`%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'),'['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')`

If the above expression is OK for your case, you could combine that for your two possible album variants (single/multi disc albums) with only one action and something like  
`$ifgreater(a,b,x,y)` (From the help: _if number a is greater than number b, x is returned, otherwise y_.)

The y-part would be your above code.  
The x-part is the one with your `\CD%discnumber%` code or the suggestion from @ohrenkino

---

<div class="post-metadata">

### Author: ![usavaci](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@usavaci](https://community.mp3tag.de/u/usavaci)
#### Post date: [February 3, 2021, 12:00pm UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/7 "2021-02-03T12:00:25Z")

</div>

@ohrenkino Is that what you mean ?  
$ifgreater(%discnumber%,1, D:\mymusic\FLAC%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')\CD%discnumber%,D:\mymusic\FLAC%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')') ) currently It worked but If the folder structure changes and if any new folder level is added then this might become fail. This is why I am triyng to figure out with a dynamic statement

---

<div class="post-metadata">

### Author: ![usavaci](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/u/7feea3/32.png) [@usavaci](https://community.mp3tag.de/u/usavaci)
#### Post date: [February 3, 2021, 12:10pm UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/8 "2021-02-03T12:10:36Z")

</div>

Currently I am using your suggested function but it create a new %ARTIST%'-'%YEAR%'-'%ALBUM% (extension) folder inside %ARTIST%'-'%YEAR%'-'%ALBUM% (extension) folder then add CD1 folder  
**a:** %discnumber%  
\*\*b:\*\*1  
**x:** `%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'), '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')\CD%discnumber%`

**y:** `%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'), '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')'))`

The final code is :  
`$ifgreater(%discnumber%,1,%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'), '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')\CD%discnumber% ,*%ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'), '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')* )`

Before running the action it was:C:\Users\u\Desktop\MP3tag deneme - Kopya\Ahkmed-2003-Ahkmed (MP3)\CD2

When I run this code for three times folder path becomes below:  
C:\Users\u\Desktop\MP3tag deneme - Kopya\Ahkmed-2003-Ahkmed (MP3)\Ahkmed-2003-Ahkmed (MP3)\Ahkmed-2003-Ahkmed (MP3)\CD2

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 3, 2021, 12:11pm UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/9 "2021-02-03T12:11:00Z")

</div>

I don't want to do dig into that maze of $ifs.  
For what I see: you have a static part that defines how far from the root of the drive your dynamic folders start, e.g.  
(a more conventional approach without all the bits and samplerates):  
`d:\mymusic\%albumartist%\%year% - %album%`[\CD %discnumber%]`  
would create folders always starting in the folder "mymusic", followed by the dynamic data for ALBUMARTIST, YEAR and ALBUM and optionally, if there is a filled DISCNUMBER, an extra folder for the separate disc.

As far as I understand your construction, the part

> [@usavaci](#):
>
> $if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")" '['%\_bitspersample%'-'$cutRight(%\_samplerate%,3)']','('$upper(%\_extension%)')')

is the same for single and multi-disc albums so you could easily simply add the `[\CD %discnumber%]` to get an optional folder for the extra disc.

Also, I think that you could simplify your statement from  
$if($eql(%\_extension%,'FLAC'),"("$upper(%\_extension%)")"  
to  
$if($eql(%\_extension%,'FLAC'),"("FLAC")"

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [February 3, 2021, 12:14pm UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/10 "2021-02-03T12:14:34Z")

</div>

> [@usavaci](#):
>
> When I run this code for three times folder path becomes below:  
> C:\Users\u\Desktop\MP3tag deneme - Kopya\Ahkmed-2003-Ahkmed (MP3)\Ahkmed-2003-Ahkmed (MP3)\Ahkmed-2003-Ahkmed (MP3)\CD2

Yes. Your code describes a relative path, relative to the currently treated file where the current folder is the starting point in the hierarchie.  
My suggestion is to use an absolute path that always uses the same starting point in the hierarchie.  
The field variables will take care of the dynamic assignment.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 9, 2026, 12:29pm UTC](https://community.mp3tag.de/t/multi-disc-album-folder-renaming-action-different-levels/51834/11 "2026-02-09T12:29:02Z")

</div>


