-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVRC_Compress.ps1
More file actions
38 lines (31 loc) · 1.95 KB
/
VRC_Compress.ps1
File metadata and controls
38 lines (31 loc) · 1.95 KB
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
37
38
# S:\my documents\My Pictures\VRChat 直下で実行してください
$targetFolders = Get-ChildItem -Directory | Where-Object { $_.Name -match '^\d{4}-\d{2}$' }
# 直下のファイルも対象に含める場合は以下を追加
$filesInRoot = Get-ChildItem -Filter *.png
function Execute-Compression($file) {
$output = Join-Path $file.DirectoryName ($file.BaseName + ".avif")
if (Test-Path $output) { return }
Write-Host "執行中 (CRCエラー無視+メタデータ移植): $($file.Name)" -ForegroundColor Cyan
# 1. Magickで変換(-defineで破損チェックをスキップし、読める部分だけで絵を作る)
magick -define png:ignore-crc=true -define png:skip-profiles=false "$($file.FullName)" -quality 50 "$output"
if ($LASTEXITCODE -eq 0 -and (Test-Path $output) -and (Get-Item $output).Length -gt 1000) {
# 2. ExifToolで「原本」から「AVIF」へ全メタデータを移植
# ここでVRChatのワールド・プレイヤー情報が復活します
exiftool -overwrite_original -TagsFromFile $file.FullName "-all:all" "$output"
# 3. タイムスタンプ(作成・更新日時)の同期
$destFile = Get-Item $output
$destFile.CreationTime = $file.CreationTime
$destFile.LastWriteTime = $file.LastWriteTime
$sizeKB = [Math]::Round($destFile.Length / 1KB)
Write-Host "成功: $sizeKB KB (メタデータ保護済)" -ForegroundColor Green
} else {
Write-Host "致命的失敗: $($file.Name) はデータが完全に消失している可能性があります" -ForegroundColor Red
if (Test-Path $output) { Remove-Item $output }
}
}
# 実行セクション
foreach ($file in $filesInRoot) { Execute-Compression $file }
foreach ($dir in $targetFolders) {
Write-Host "--- フォルダ巡回中: $($dir.Name) ---" -ForegroundColor Magenta
Get-ChildItem -Path $dir.FullName -Filter *.png | ForEach-Object { Execute-Compression $_ }
}