$root = 'Y:\Приложения\Tilda Publishing and Disk'
$out = Join-Path ([Environment]::GetFolderPath('Desktop')) (
'DOL_photo_audit_' + (Get-Date -Format 'yyyyMMdd_HHmmss')
)
New-Item -ItemType Directory -Path $out | Out-Null
$scanErrors = @()
$files = @(Get-ChildItem -LiteralPath $root -File -Recurse -Force `
-ErrorAction SilentlyContinue -ErrorVariable +scanErrors)
$inventory = @(
foreach ($file in $files) {
$relative = $file.FullName.Substring($root.Length).TrimStart('\')
$area = if ($relative -like 'make\*') { 'make' } else { 'source_or_other' }
[pscustomobject]@{
Area = $area
Name = $file.Name
Bytes = $file.Length
LastWriteUtc = $file.LastWriteTimeUtc.ToString('o')
RelativePath = $relative
FullPath = $file.FullName
}
}
)
$zero = @($inventory | Where-Object { $_.Bytes -eq 0 })
$inventory | Export-Csv (Join-Path $out 'all_files.csv') `
-NoTypeInformation -Encoding UTF8
$zero | Export-Csv (Join-Path $out 'zero_files.csv') `
-NoTypeInformation -Encoding UTF8
$scanErrors | ForEach-Object { $_.ToString() } |
Out-File (Join-Path $out 'scan_errors.txt') -Encoding UTF8
$summary = [pscustomobject]@{
FilesListed = $inventory.Count
ZeroByteFiles = $zero.Count
ZeroInMake = @($zero | Where-Object Area -eq 'make').Count
ZeroOutsideMake = @($zero | Where-Object Area -ne 'make').Count
UniqueZeroNames = @($zero.Name | Sort-Object -Unique).Count
ScanErrors = $scanErrors.Count
Results = $out
}
$summary | Format-List
$summary | ConvertTo-Json | Set-Content (Join-Path $out 'summary.json') -Encoding UTF8