Foobar2000 Replace & Rename Folder Name

Discussion about programs used to manage files and libraries (Foobar2000, iTunes, Musicbee, DeaDBeeF)
Post Reply
Mr.V600
lvl 1
Posts: 204
Joined: Thu Jul 13, 2023 9:50 am

Foobar2000 Replace & Rename Folder Name

Post by Mr.V600 »

Here is a way to change folder name of an album in Foobar2000 using the song tags.
foobar2000 rename folder.jpg
foobar2000 rename folder.jpg (69.8 KiB) Viewed 149 times
You will need to save a template for each drive letter, since the Destination Folder can't using formatting variables. You have to at least hard code the drive letter.

Enable "Move Entire Source Folder Content" and "Remove Empty Source Folders"

The important part is this:
$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)

Starting with the base file path
D:\EAC\Images\VinylStudio\Ripped Albums\Roman Trip Cinderella's Labyrinth

Breaking it down

$directory(path) - Extracts only the directory name from the file path.
$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)
D:\EAC\Images\VinylStudio\Ripped Albums\Roman Trip Cinderella's Labyrinth

$directory(path,n) - Extracts directory name from the file path; goes up by n levels.
$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)
Roman Trip Cinderella's Labyrinth

$replace(str,search,replace) - Replaces all occurrences of string search in string str with string replace.
$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)
This will search "D:\EAC\Images\VinylStudio\Ripped Albums\Roman Trip Cinderella's Labyrinth" and find "Roman Trip Cinderella's Labyrinth" and replace with nothing, which produces the following:
D-\EAC\Images\VinylStudio\Ripped Albums\
The "D-" is actually "D:", but Foobar2000 is doing a special character replacement because colons aren't allowed in Windows filenames.

So then the whole thing looks like this after the inner replace is filled in. The outer replace is to fix that "D:" problem
$replace(D-\EAC\Images\VinylStudio\Ripped Albums\,D:,)
\EAC\Images\VinylStudio\Ripped Albums\

Here is a basic template. Remember this only changes the current folder the tracks are in. It does not change the folders before that.
$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)%album% '['%date%']' \$ifgreater(%totaldiscs%,1,%disc number%'-',)%track% %title%
foobar2000 rename folder 2.jpg
Here is my custom one that does additional character replacement and puts the codec and catalog ID in the folder title.
It also replaces colons : and forward slashes / with characters that are Windows friendly for the album name.

$replace($replace($directory_path(%path%),$directory(%path%,1),),D:,)'\['%date%']' $replace(%album%,:,։,/,/)$if(%alttitle%,' ('$replace(%alttitle%,:,։)')',)$if(%catalog%,' ['%catalog%']',)$if(%source%,' ['%source%']',) '['%codec%']'$ifgreater(%__bitspersample%,23,' ['%__bitspersample%'/'$left(%samplerate%,$sub($len(%samplerate%),3))'Khz] ',)$if(%LOG%,' ['LOG']',)$if(%SCANS%,' ['SCANS'] ',)$ifgreater(%totaldiscs%,1,'['%totaldiscs%'CD]',)\$ifgreater(%totaldiscs%,1,%disc number%'-',)%track% %title%

Tags:
Post Reply