2

I have a few folders containing mp3 files (folder names CD#1 CD#2) with a few files in each folder. I renamed the Album name and changed the track number so my iPod should store it as one long audiobook.

But the title name is messed up, I want to rename the title so that it should display Track 1, Track 2 etc.

I tried using mp3tag but was unsuccessful creating a dynamic title name (i.e that each file should have the next number Track 1, Track 2).

Any way that I can do that?

2 Answers 2

2

If you already have the proper track numbers you can try a hack with EasyTAG: first, rename the files to include the track number then read the track number into the title field by treating it as an element of the title.

In particular: use the renaming pattern Track %n and then read back using the pattern %t.

Back up your files before experimenting with this solution!

4
  • It worked (I'm using mp3tag) but now I can't get back my original file names since it's all renamed track 1 etc. I can undo my actions to get back the names but then I lose the new title names too. Jun 9, 2011 at 23:01
  • @randomBananas you can try the following trick: first store the name in a "less important" field, or a field which is the same for every track (e.g. author or comment) then apply the procedure outlined above and then restore the file name from this field and finally restore this field.
    – bandi
    Jun 9, 2011 at 23:17
  • Thank you Bandi it worked; though it required many renamings for what seems like a simple task. It's a shame these programs only allow dynamic naming in the filename, they should allow dynamic naming in the title (and other ID3 tags) I tried originally inserting %track% in the title it simply renames all titles "%track%". Jun 9, 2011 at 23:44
  • @bandi: Can you explain this method in more steps. I'm not following how to do it.
    – MountainX
    Mar 9, 2012 at 4:27
0

Back in 2021 the directory structure of a hard drive that contained downloaded video packages got corrupted.

I used a deep recovery program that got all the individual files back plus multiple copies of old deleted files but the folders were gone and the file names were renamed to a generic filename. I ended up re-downloading everything I could instead.

But now I need files that are no longer on the web but might be in that archive. I spent yesterday and this morning looking at various code to "rename the file to the Title" and here is what I worked out removing all unnecessary operations.

I added error checking to skip files that have a $null Title or if it was already renamed to the Title. Illegal characters in a filename are replaced with underscores '_'. I added a counter in case there are multiple files with the same Title and append that number in the filename.

It took me a bit to understand what wasn't actually needed in the example code I was learning from. The $PrevT was for my debugging only so I could see it progress through the file list.

$file   = ""
$Title  = ""
$blah   = 0
#$PrevT = ""
#$illegalchars2 = [string]::join('',([System.IO.Path]::GetInvalidFileNameChars())) -replace '\\','\\'
$illegalchars2 = '"<>|:*?\\/'
$LocalDir = 'K:\recup_folders\recup_dir.1\temp\'
$FType    = '.mp4'
$AllFiles = Get-ChildItem $LocalDir -Filter *.mp4
$ShellApplication = New-Object -ComObject Shell.Application

foreach ($SingleFile in $AllFiles)
{
    $blah   = $blah + 1
    $folder = ShellApplication.Namespace($SingleFile.Directory.FullName)         
    $file   = $folder.ParseName($SingleFile.Name)
    $Title  = $file.ExtendedProperty('System.Title')
    #$FixT   = ([char[]]$Title | where { [IO.Path]::GetinvalidFileNameChars() -notcontains $_ }) -join ''
    $FixT   = $Title
    $FixedT = $FixT -replace "[$illegalchars2]",'_'

    if ($null -ne $Title)
    {
        $OldName = "$LocalDir$Singlefile"
        $NewName = "$LocalDir$FixedT$FType"
        '-----------------'
        #"Previous: $PrevT"
        "Current File: $Singlefile"
        "Unfixed Title: $Title"
        "FixedT: $FixedT"
        "OldName: $OldName"
        if ($OldName -eq $NewName)
        { 'Skipping file already fixed.' }
        else
        {
            if ((Test-Path -Path $NewName -PathType Leaf))
            {
                "Repeat File detected: $NewName"
                $NewName = "$LocalDir$FixedT($blah)$FType"
            }
            "Final New Name: $NewName"
            Rename-Item $OldName -NewName $NewName
            '----Done---------
            '
        }
        #$PrevT = $Title
    }
    else { "Skipping blank Title file: $Singlefile" }
}  

Sample output:

-----------------
Current File: 00PM - Four Points by Sheraton Orlando ✅.mp4
Unfixed Title: Flat Earth Meetup Florida - April 14 - 7:00PM - Four Points by Sheraton Orlando ✅
FixedT: Flat Earth Meetup Florida - April 14 - 7_00PM - Four Points by Sheraton Orlando ✅
OldName: K:\recup_folders\recup_dir.1\temp\00PM - Four Points by Sheraton Orlando ✅.mp4
Final New Name: K:\recup_folders\recup_dir.1\temp\Flat Earth Meetup Florida - April 14 - 7_00PM - Four Points by Sheraton Orlando ✅.mp4
----Done---------

-----------------
Current File: Black Death talks Flat Earth on Heavy Metal Relics ✅.mp4
Unfixed Title: Black Death talks Flat Earth on Heavy Metal Relics ✅
FixedT: Black Death talks Flat Earth on Heavy Metal Relics ✅
OldName: K:\recup_folders\recup_dir.1\temp\Black Death talks Flat Earth on Heavy Metal Relics ✅.mp4
Skipping file already fixed.
-----------------
Current File: f11860480.mp4
Unfixed Title: Flat Earth Man "Welcome to the Satellite Hoax" ✅
FixedT: Flat Earth Man _Welcome to the Satellite Hoax_ ✅
OldName: K:\recup_folders\recup_dir.1\temp\f11860480.mp4
Final New Name: K:\recup_folders\recup_dir.1\temp\Flat Earth Man _Welcome to the Satellite Hoax_ ✅.mp4
----Done---------

-----------------
Current File: f11981680.mp4
Unfixed Title: Flat Earth Man "Welcome to the Satellite Hoax" ✅
FixedT: Flat Earth Man _Welcome to the Satellite Hoax_ ✅
OldName: K:\recup1\recup_folders\recup_dir.1\temp\f11981680.mp4
Repeat File detected: K:\recup_folders\recup_dir.1\temp\Flat Earth Man _Welcome to the Satellite Hoax_ ✅.mp4
Final New Name: K:\recup_folders\recup_dir.1\temp\Flat Earth Man _Welcome to the Satellite Hoax_ ✅(4).mp4
----Done---------

-----------------
Current File: f13881504.mp4
Unfixed Title: Example: <of> /bad\ *bad?
FixedT: Example_ _of_ _bad_ _bad_
OldName: K:\recup_folders\recup_dir.1\temp\f13881504.mp4
Final New Name: K:\recup_folders\recup_dir.1\temp\Example_ _of_ _bad_ _bad_.mp4
----Done---------

Skipping blank Title file: f18489568.mp4
-----------------
Current File: Rock and Roll Flat Earth Song  Music - The Zetetic Astronomers by Neo Retros - Mark Sargent ✅.mp4
Unfixed Title: Rock and Roll Flat Earth Song / Music - The Zetetic Astronomers by Neo Retros - Mark Sargent ✅
FixedT: Rock and Roll Flat Earth Song _ Music - The Zetetic Astronomers by Neo Retros - Mark Sargent ✅
OldName: K:\recup_folders\recup_dir.1\temp\Rock and Roll Flat Earth Song  Music - The Zetetic Astronomers by Neo Retros - Mark Sargent ✅.mp4
Final New Name: K:\recup_folders\recup_dir.1\temp\Rock and Roll Flat Earth Song _ Music - The Zetetic Astronomers by Neo Retros - Mark Sargent ✅.mp4
----Done---------

Posts I used to figure this out by taking a key piece of each:

You must log in to answer this question.

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