[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$Path, [string[]]$Extension = @('.mp3', '.flac', '.m4a', '.aac', '.ogg', '.wav'), [string]$Csv ) $ErrorActionPreference = 'Stop' $resolved = Resolve-Path -LiteralPath $Path -ErrorAction Stop if (-not (Test-Path -LiteralPath $resolved -PathType Container)) { throw "Укажите папку с аудио: $resolved" } $files = Get-ChildItem -LiteralPath $resolved -File -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Extension -in $Extension } if (-not $files) { Write-Host 'Аудиофайлы не найдены.' exit 0 } $shell = New-Object -ComObject Shell.Application $rows = foreach ($file in $files) { $artist = '' $album = '' $title = '' try { $folder = $shell.Namespace($file.DirectoryName) $item = $folder.ParseName($file.Name) if ($item) { $artist = [string]$item.ExtendedProperty('System.Music.Artist') $album = [string]$item.ExtendedProperty('System.Music.AlbumTitle') $title = [string]$item.ExtendedProperty('System.Title') } } catch { Write-Warning "Свойства не прочитаны: $($file.FullName)" } $missing = @() if ([string]::IsNullOrWhiteSpace($artist)) { $missing += 'artist' } if ([string]::IsNullOrWhiteSpace($album)) { $missing += 'album' } if ([string]::IsNullOrWhiteSpace($title)) { $missing += 'title' } if ($missing.Count -gt 0) { [pscustomobject]@{ File = $file.FullName Missing = ($missing -join ', ') SizeMB = [math]::Round($file.Length / 1MB, 2) } } } [void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($shell) if (-not $rows) { Write-Host 'У всех файлов есть основные теги.' exit 0 } $rows | Format-Table -AutoSize -Wrap Write-Host "Файлов без части тегов: $($rows.Count)" if ($Csv) { $rows | Export-Csv -LiteralPath $Csv -NoTypeInformation -Encoding UTF8 Write-Host "Отчёт сохранён: $Csv" }