Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .