Batch rename of folders (append with suffix)

rhouck

2[H]4U
Joined
Apr 15, 2002
Messages
3,597
I am looking for a solution to batch rename folders from "Name" to "Name [FLAC]".

My music is currently divided into two main folders: one for lossless (flac) files and one for all other (mainly mp3). I would like to consolidate them but would like to make it easy to see from a folder level which albums are lossless.

The format is \\Quality\Artist\Album

For example:
\\Music-Lossless\A Perfect Circle\Mer de Noms
\\Music\A Perfect Circle\Thirteenth Step

I would like to have all the "Album" folders renamed to "Album [FLAC]".

So "\\Music-Lossless\A Perfect Circle\Mer de Noms [FLAC]" would be the result.

There are ~500 Artists in my Lossless folder, each with various Albums as subdirectories, thus the desire to have this done as a batch rename. It would need to be recursive down one folder level (as I'd prefer to not have to go artist-by-artist).

Suggestions on programs or command line way to do this?
 
Here's a PowerShell script that does it, PowerShell is included in Windows 7, the first time you run PowerShell, you need to run it as Admin and run the command "Set-executionpolicy RemoteSigned" to enable you to run scripts. Save it as 'batchrename.ps1' and run it by typing '.\batchrename.ps1 [directory of Music-Lossless]' so for example '.\batchrename.ps1 c:\users\bob\music\music-lossless'

Code:
if ($args.count -ne 1) {echo "Requires 1 argument. Exiting."; exit}
$musicdir=$args[0]
 
if ((get-item -ea 0 $musicdir).exists -eq $false) {echo "$musicdir does not exist. Exiting.";exit}
 
$artists=(dir (get-item $musicdir).fullname | ?{$_.mode -match "d"})
 
foreach ($artist in $artists)
{
    $albums = (dir $artist.fullname | ?{$_.mode -match "d"})
    foreach ($album in $albums)
    {
        mv -literalpath $album.fullname "$($album.fullname) [FLAC]"
    }
}
 
Thanks for the help, I believe this will work perfectly for my needs.
 
Back
Top