versioned name handling more accurate

This commit is contained in:
Nathan
2025-12-30 15:53:09 -07:00
parent 60c03aadc0
commit 7a4e9b6662
2 changed files with 2621 additions and 1117 deletions

View File

@@ -533,6 +533,7 @@ if ($null -ne $flatColorsMoveLog -and $flatColorsMoveLog.Count -gt 0) {
$blendFileParentDir = Split-Path -Path $textureFolderPath -Parent $blendFileParentDir = Split-Path -Path $textureFolderPath -Parent
# Find matching blend files # Find matching blend files
# Match logic: blendfile folder name (e.g., "Beth") should appear in blend file name (e.g., "AM_Beth_v3.2.blend")
$blendFileMappings = @() $blendFileMappings = @()
if ($null -ne $blendfileFolders -and $blendfileFolders.Count -gt 0) { if ($null -ne $blendfileFolders -and $blendfileFolders.Count -gt 0) {
# Get blendfile folder names # Get blendfile folder names
@@ -543,20 +544,20 @@ if ($null -ne $blendfileFolders -and $blendfileFolders.Count -gt 0) {
if ($null -ne $blendFiles -and $blendFiles.Count -gt 0) { if ($null -ne $blendFiles -and $blendFiles.Count -gt 0) {
foreach ($blendFile in $blendFiles) { foreach ($blendFile in $blendFiles) {
# Extract prefix from blend file name (e.g., "Chan_v4.3.blend" -> "Chan")
$blendFileName = $blendFile.BaseName $blendFileName = $blendFile.BaseName
$parts = $blendFileName.Split('_', 2)
if ($parts.Length -ge 1) { # Check if any blendfile folder name appears in the blend file name
$prefix = $parts[0] foreach ($folderName in $blendfileFolderNames) {
# Match folder name when surrounded by underscores, dots, hyphens, or at start/end
# Check if prefix matches any blendfile folder name # This avoids partial matches (e.g., "Beth" in "Bethany") while allowing "Beth" in "AM_Beth_v3.2"
if ($blendfileFolderNames -contains $prefix) { $escapedFolderName = [regex]::Escape($folderName)
if ($blendFileName -match "(^|[._-])$escapedFolderName([._-]|$)") {
$blendFileMappings += [PSCustomObject]@{ $blendFileMappings += [PSCustomObject]@{
BlendFile = [System.IO.Path]::GetFullPath($blendFile.FullName) BlendFile = [System.IO.Path]::GetFullPath($blendFile.FullName)
BlendfileFolder = $prefix BlendfileFolder = $folderName
} }
Write-Host "Found matching blend file: $($blendFile.Name) -> $prefix" -ForegroundColor Gray Write-Host "Found matching blend file: $($blendFile.Name) -> $folderName" -ForegroundColor Gray
break # Only match once per blend file
} }
} }
} }