Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've just finished creating SHA1 hashes for each album in my MP3 collection using Corz Checksum. It left a .hash file in each folder, as desired. (Each folder is an album.)

However, the hash files it generated all have the name of the folder, for example

The Beatles - 1966 - Revolver.hash

I would like to automatically rename all of these .hash files to match the name of the .m3u playlist file which every folder also contains. For example the presence of

00 - Revolver.m3u

should cause the hash file to be renamed to

00 - Revolver.hash

Does anyone know of a way to do this with a command line? I'm hoping to find something similar to this: Command line recursive rename\move in windows?

share|improve this question

1 Answer 1

You can do this with PowerShell, if you're comfortable with that.

function Rename-HashFiles ([string]$path)
{
    [System.IO.FileInfo[]]$hashFiles = Get-ChildItem -Path $path -Force -Include "*.hash" -Recurse
    foreach($hashFile in $hashFiles)
    {
        [string]$newFileName = [string]::Empty;
        Get-ChildItem -Path ($hashFile.DirectoryName) -Filter "*.m3u" | % { $newFileName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name) }    
        $newFileName += ([System.IO.Path]::GetExtension($hashFile.Name))
        Rename-Item -Path $hashFile.FullName -NewName $newFileName
    }

}

Rename-HashFiles "C:\My_Music_Folder"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.