-
-
Save arn-ob/67fb3374bd5a27c596b5f6cd616b0a93 to your computer and use it in GitHub Desktop.
Get MetaData from a .MP3 or .MP4 file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-MP3MetaData | |
{ | |
[CmdletBinding()] | |
[Alias()] | |
[OutputType([Psobject])] | |
Param | |
( | |
[String] [Parameter(Mandatory=$true, ValueFromPipeline=$true)] $Directory | |
) | |
Begin | |
{ | |
} | |
Process | |
{ | |
Foreach($Dir in $Directory) | |
{ | |
$ObjDir = $shell.NameSpace($Dir) | |
$Files = gci $Dir| ?{$_.Extension -in '.mp3','.mp4'} | |
Foreach($File in $Files) | |
{ | |
$ObjFile = $ObjDir.parsename($File.Name) | |
$MetaData = @{} | |
$MP3 = ($ObjDir.Items()|?{$_.path -like "*.mp3" -or $_.path -like "*.mp4"}) | |
$PropertArray = 0,1,2,12,13,14,15,16,17,18,19,20,21,22,27,28,36,220,223 | |
Foreach($item in $PropertArray) | |
{ | |
If($ObjDir.GetDetailsOf($ObjFile, $item)) #To avoid empty values | |
{ | |
$MetaData[$($ObjDir.GetDetailsOf($MP3,$item))] = $ObjDir.GetDetailsOf($ObjFile, $item) | |
} | |
} | |
New-Object psobject -Property $MetaData |select *, @{n="Directory";e={$Dir}}, @{n="Fullname";e={Join-Path $Dir $File.Name -Resolve}}, @{n="Extension";e={$File.Extension}} | |
} | |
} | |
} | |
End | |
{ | |
} | |
} | |
#ForEach($item in ("D:\Powershell\Tutorials\4_DSC" |Get-MP3MetaData)){ | |
# $NewName = [regex]::Replace($(($item.Title).Split(":")[1].Trim() + $item.extension),"[*(/)\\&#]",{''}) | |
# $Oldname = $item.Fullname | |
# Rename-Item -LiteralPath $item.Fullname -NewName $NewName -Force | |
#} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment