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?

Giacomo1968
  • 58,727

2 Answers2

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!

bandi
  • 674
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 = &quot;$LocalDir$Singlefile&quot;
    $NewName = &quot;$LocalDir$FixedT$FType&quot;
    '-----------------'
    #&quot;Previous: $PrevT&quot;
    &quot;Current File: $Singlefile&quot;
    &quot;Unfixed Title: $Title&quot;
    &quot;FixedT: $FixedT&quot;
    &quot;OldName: $OldName&quot;
    if ($OldName -eq $NewName)
    { 'Skipping file already fixed.' }
    else
    {
        if ((Test-Path -Path $NewName -PathType Leaf))
        {
            &quot;Repeat File detected: $NewName&quot;
            $NewName = &quot;$LocalDir$FixedT($blah)$FType&quot;
        }
        &quot;Final New Name: $NewName&quot;
        Rename-Item $OldName -NewName $NewName
        '----Done---------
        '
    }
    #$PrevT = $Title
}
else { &quot;Skipping blank Title file: $Singlefile&quot; }

}

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:

Giacomo1968
  • 58,727