-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp3Renamer.ps1
36 lines (29 loc) · 1.17 KB
/
mp3Renamer.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<#
.SYNOPSIS Mp3-Renamer
.DESCRIPTION
.NOTES Author: Gill Bates, Last Update: 07.11.2021
#>
[string]$Path = "C:\Users\Tobias\Downloads\BENGR_-_Blow_The_Speakers_(Extended_Mix)-(DWX1507)-WEB-2023"
[int]$leadingNumbers = 3
function Rename-Mp3 {
Param(
[parameter(Mandatory = $true)]
[String]$Path,
[parameter(Mandatory = $true)]
[int]$leadingNumbers
)
$allMp3 = Get-ChildItem -Path $Path -Filter *.mp3 -Recurse
Write-Information "[OK] Fetched total '$($allMp3.Count)' MP3-Files!" -InformationAction Continue
$output = New-Item -Path $Path -Name "_Rename" -ItemType "directory" -Force
$TextInfo = (Get-Culture).TextInfo
$count = 1
$allMp3 | ForEach-Object {
Copy-Item $_.FullName -Destination $output -Force
$_.BaseName.substring($leadingNumbers) -replace '_', ' ' -replace "and", "&" | ForEach-Object {
$newCamelCase = $TextInfo.ToTitleCase($_).Trim()
}
Write-Information "[$Count/$($allMp3.Count)] Renaming '$newCamelCase' ..." - -InformationAction Continue
Rename-Item -Path "$output\$($_.PSChildName)" -NewName ($newCamelCase + $_.Extension)
$count++
}
}