-
Notifications
You must be signed in to change notification settings - Fork 327
Description
"Morton Feldman - Sabat / Clarke" becomes:
"Morton Feldman - Sabat Clarke"
$taglib = "d:\tools\taglib-sharp.dll"
[system.reflection.assembly]::loadfile($taglib)
function find_artist {
$=$args[0]
$media = [taglib.file]::create($.FullName)
$tags = $media.GetTag('Id3v2')
$fileperformers = $tags.performers
$filealbumartists = $tags.albumartists
if (-not ( $fileperformers -eq $null) -and [string]::IsNullOrEmpty($fileperformers) -eq $False ) {
return $fileperformers
} elseif ( -not ( $filealbumartists -eq $null ) -and [string]::IsNullOrEmpty($filealbumartists) -eq $False ) {
return $filealbumartists
} else {
return $False
}
}
$basepath="D:\files"
$a = Get-ChildItem $basepath -recurse | Where-Object {$_.PSIsContainer -eq $True}
if ( $.FullName -like '*mp3' -or $.FullName -like '*flac' -or $.FullName -like '*m4a' -or $.FullName -like '*wav') {
if (Test-Path -LiteralPath $.FullName) {
$artist=find_artist $
if (-not ( $artist -eq $False) ) {
if ( ( -not ( $artist -match "&") ) -and ( -not ( $artist -match "/" ) ) ) {
$dir=Split-Path -Path $_.FullName -Parent
if ( -not ( "$dir" -like "$basepath$artist*" ) -and -not ("$dir" -like "$basepath$artist") ) {
write-host "dir" $dir
write-host "$basepath$artist"
write-host $artist
if (-not(Test-Path -LiteralPath "$basepath$artist") ) {
New-Item -Path "$basepath" -Name "$artist" -ItemType "directory"
}
move-item -literalpath "$dir" -destination "$basepath$artist" -Force
}
} else {
write-host "$artist"
}
}
}
}
}