Compare commits
3 Commits
9b6b461c22
...
abc668e1d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abc668e1d3 | ||
|
|
d77af346b7 | ||
|
|
47a05bf4f2 |
@@ -1,4 +1,4 @@
|
||||
<!-- Generated by SpecStory -->
|
||||
<!-- Generated by SpecStory, Markdown v2.1.0 -->
|
||||
|
||||
<!-- cursor Session faf4db6e-9d08-4e79-906f-d2f51852154f (2025-10-27 16:57Z) -->
|
||||
|
||||
@@ -10,9 +10,10 @@ _**User (2025-10-27 21:59Z)**_
|
||||
|
||||
---
|
||||
|
||||
_**Assistant (gpt-5)**_
|
||||
_**Agent (model gpt-5, mode Agent)**_
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Creating a work todo list**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Creating a work todo list**
|
||||
|
||||
I see we have a Windows PowerShell environment, but tools aren't running there. I think I should create a todo list for re-applying work configuration. That sounds moderately complex, including updates across scripts and ensuring paths for the work environment.
|
||||
|
||||
@@ -27,37 +28,48 @@ I'll scan the scripts to see what's currently configured (likely "home" mode), t
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_file**
|
||||
<tool-use data-tool-type="read" data-tool-name="read_file">
|
||||
<details><summary>Tool use: **read_file** • Read file: UpdateSequences.ps1</summary>
|
||||
|
||||
Read file: UpdateSequences.ps1
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_file**
|
||||
<tool-use data-tool-type="read" data-tool-name="read_file">
|
||||
<details><summary>Tool use: **read_file** • Read file: UpdateSequences.bat</summary>
|
||||
|
||||
Read file: UpdateSequences.bat
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_file**
|
||||
<tool-use data-tool-type="read" data-tool-name="read_file">
|
||||
<details><summary>Tool use: **read_file** • Read file: UpdateAllSequences.bat</summary>
|
||||
|
||||
Read file: UpdateAllSequences.bat
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_file**
|
||||
<tool-use data-tool-type="read" data-tool-name="read_file">
|
||||
<details><summary>Tool use: **read_file** • Read file: UpgradeSeqBatches.ps1</summary>
|
||||
|
||||
Read file: UpgradeSeqBatches.ps1
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_file**
|
||||
<tool-use data-tool-type="read" data-tool-name="read_file">
|
||||
<details><summary>Tool use: **read_file** • Read file: outline.txt</summary>
|
||||
|
||||
Read file: outline.txt
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Reapplying work configuration**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Reapplying work configuration**
|
||||
|
||||
I need to re-apply the "work configuration" to the repo since they mentioned losing the entire work in Gitea. I see we previously updated UpdateSequences.ps1 for home mode, but now must switch scripts back to work configuration. Currently, we have UpdateSequences.ps1 and UpdateSequences.bat pointing to a work path. The PS1 seems to use a working directory root and might have different naming and destination rules. However, we only have the history document for home, so I must figure out what "work configuration" entails based on the context.
|
||||
**Clarifying work configuration**
|
||||
@@ -73,10 +85,9 @@ I’m going to look for patterns indicating the “work” mode (e.g., daily_* s
|
||||
|
||||
---
|
||||
|
||||
Tool use: **grep**
|
||||
|
||||
<tool-use data-tool-type="search" data-tool-name="grep">
|
||||
<details>
|
||||
<summary>Grep for "daily_" • 32 matches</summary>
|
||||
<summary>Tool use: **grep** • Grep for "daily_" • 32 matches</summary>
|
||||
|
||||
Output mode: content
|
||||
|
||||
@@ -118,10 +129,12 @@ Output mode: content
|
||||
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Evaluating script updates**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Evaluating script updates**
|
||||
|
||||
I'm looking at `UpdateSequences.bat`, where the path points to the repo script. The thing is, while `$currentDir` seems fine for both, there's a preference to avoid writing plans to a file and instead output to the console. But for a work environment, it might make sense to save the plan to `_UpdatePlan.txt` instead. Currently, the script prints to the console, and earlier changes emphasize direct console output, which could be part of home rules. I think implementing a `-Mode` parameter to toggle between Work and Home options could work.
|
||||
**Adjusting script behavior**
|
||||
@@ -130,10 +143,9 @@ I'm thinking about how to adjust the scanning patterns and plan writing. The ins
|
||||
|
||||
---
|
||||
|
||||
Tool use: **grep**
|
||||
|
||||
<tool-use data-tool-type="search" data-tool-name="grep">
|
||||
<details>
|
||||
<summary>Grep for "_UpdatePlan.txt" • 1 match</summary>
|
||||
<summary>Tool use: **grep** • Grep for "_UpdatePlan.txt" • 1 match</summary>
|
||||
|
||||
Output mode: content
|
||||
|
||||
@@ -144,10 +156,12 @@ Output mode: content
|
||||
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Interpreting configuration requests**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Interpreting configuration requests**
|
||||
|
||||
I need to focus on the user's request about their Gitea work and re-applying the work configuration to their repo. They mention a spec file that details editing a script, and it seems like they want to revert to a work mode with different scanning patterns. I should confirm what "work configuration" specifically means since the current scripts are set to a "home" mode. The distinction and pathing between local and centralized scripts need understanding to ensure the right setup.
|
||||
**Analyzing work configuration setups**
|
||||
@@ -169,10 +183,9 @@ I'll switch the daily folder scan in `UpdateSequences.ps1` from date-based (YYYY
|
||||
|
||||
---
|
||||
|
||||
Tool use: **apply_patch**
|
||||
|
||||
<tool-use data-tool-type="write" data-tool-name="apply_patch">
|
||||
<details>
|
||||
<summary>Apply patch for UpdateSequences.ps1</summary>
|
||||
<summary>Tool use: **apply_patch** • Apply patch for UpdateSequences.ps1</summary>
|
||||
|
||||
|
||||
```diff
|
||||
@@ -186,12 +199,14 @@ Tool use: **apply_patch**
|
||||
*** End Patch
|
||||
```
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **read_lints**
|
||||
|
||||
<tool-use data-tool-type="generic" data-tool-name="read_lints">
|
||||
<details>
|
||||
<summary>Read lints for 1 file</summary>
|
||||
<summary>Tool use: **read_lints** • Read lints for 1 file</summary>
|
||||
|
||||
Lint paths:
|
||||
|
||||
@@ -202,19 +217,20 @@ Lint results
|
||||
|
||||
**No lint errors found**
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Analyzing file structure**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Analyzing file structure**
|
||||
|
||||
It looks like the work environment is using an absolute path for the `ps1` file in a specified directory, but inside `UpdateSequences.ps1`, it's relying on the current directory for both scanning and destination. I wonder if the work configuration is trying to mirror subfolders in "Renders." Previously, "_CURRENT" was used in the project root, but maybe "Current" is the new destination. To clarify, I'll search through the repository for any instances of "_CURRENT."</details></think>
|
||||
|
||||
---
|
||||
|
||||
Tool use: **grep**
|
||||
|
||||
<tool-use data-tool-type="search" data-tool-name="grep">
|
||||
<details>
|
||||
<summary>Grep for "_CURRENT" • 8 matches</summary>
|
||||
<summary>Tool use: **grep** • Grep for "_CURRENT" • 8 matches</summary>
|
||||
|
||||
Output mode: content
|
||||
|
||||
@@ -232,10 +248,12 @@ Output mode: content
|
||||
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
<think><details><summary>Thought Process</summary>**Analyzing user instructions**
|
||||
<think><details><summary>Thought Process</summary>
|
||||
**Analyzing user instructions**
|
||||
|
||||
I need to follow the developer's instructions carefully based on the user's request. They mentioned a loss of work in gitea and want to re-apply a "work configuration." I need to figure out what that configuration entails, looking back at the attached history file that describes past modifications. It seems we switched scanning formats to 'daily_*' recently, which might be part of the "work" mode. I should also verify path references to ensure we're aligned with the correct environment.
|
||||
**Evaluating script adjustments**
|
||||
@@ -265,15 +283,17 @@ I switched the scan to use daily_* and verified the batch scripts and robocopy f
|
||||
|
||||
---
|
||||
|
||||
Tool use: **todo_write**
|
||||
|
||||
## Todo List
|
||||
<tool-use data-tool-type="task" data-tool-name="todo_write">
|
||||
<details><summary>Tool use: **todo_write** • Todo List</summary>
|
||||
|
||||
- [x] Switch UpdateSequences.ps1 daily scan to daily_* (work mode)
|
||||
- [x] Verify UpdateSequences.bat points to central work path
|
||||
- [x] Confirm robocopy flags mirror (/MIR) for work setup
|
||||
- [x] Sanity-check logs/summary for work run
|
||||
|
||||
</details>
|
||||
</tool-use>
|
||||
|
||||
---
|
||||
|
||||
- Switched `UpdateSequences.ps1` to scan `daily_*` folders instead of date-based names.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dailyFormat": "YYYY-MM-DD",
|
||||
"structDir": "D:\\0 ProjectStructure",
|
||||
"structDir": "A:\\1 Amazon_Active_Projects\\3 ProjectStructure",
|
||||
"zipper": "7z",
|
||||
"compression": 0,
|
||||
"Max7zInst": 0
|
||||
|
||||
@@ -21,6 +21,9 @@ if (-not (Test-Path -Path $textureFolderPath -PathType Container)) {
|
||||
$textureFolderPath = (Resolve-Path $textureFolderPath).ProviderPath
|
||||
Write-Host "Processing texture folder: $textureFolderPath" -ForegroundColor Cyan
|
||||
|
||||
# Add required .NET assemblies for image processing (for FlatColors standardization)
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
# Function to calculate checksums for files
|
||||
function Get-FilesWithChecksums {
|
||||
param(
|
||||
@@ -266,6 +269,81 @@ function Process-DuplicateGroup {
|
||||
}
|
||||
}
|
||||
|
||||
# Function to extract and normalize hex color code from filename (for FlatColors)
|
||||
function Get-NormalizedColorCode {
|
||||
param([string]$FileName)
|
||||
|
||||
# Remove extension
|
||||
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($FileName)
|
||||
|
||||
# Match hex color pattern: #RRGGBB or #RRGGBBAA (with optional suffix like _1, _2, etc.)
|
||||
# Pattern matches: #RRGGBB, #RRGGBBAA, or just RRGGBB (without #)
|
||||
# Also handles suffixes like _1, _2, etc.
|
||||
if ($baseName -match '^(#?)([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?') {
|
||||
$hasHash = $Matches[1] -eq "#"
|
||||
$hexCode = $Matches[2].ToUpper()
|
||||
# Return normalized format: #RRGGBB (always with #, always uppercase, no suffix)
|
||||
return "#$hexCode"
|
||||
}
|
||||
|
||||
return $null
|
||||
}
|
||||
|
||||
# Function to convert and resize image to 16x16 JPG (for FlatColors)
|
||||
function Convert-To16x16Jpg {
|
||||
param(
|
||||
[string]$SourcePath,
|
||||
[string]$DestinationPath
|
||||
)
|
||||
|
||||
try {
|
||||
$image = [System.Drawing.Image]::FromFile($SourcePath)
|
||||
|
||||
# Create 16x16 bitmap
|
||||
$bitmap = New-Object System.Drawing.Bitmap(16, 16)
|
||||
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
|
||||
$graphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
|
||||
$graphics.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::HighQuality
|
||||
$graphics.PixelOffsetMode = [System.Drawing.Drawing2D.PixelOffsetMode]::HighQuality
|
||||
|
||||
# Draw resized image
|
||||
$graphics.DrawImage($image, 0, 0, 16, 16)
|
||||
|
||||
# Get JPEG codec
|
||||
$jpegCodec = [System.Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | Where-Object { $_.MimeType -eq "image/jpeg" }
|
||||
$encoderParams = New-Object System.Drawing.Imaging.EncoderParameters(1)
|
||||
$encoderParams.Param[0] = New-Object System.Drawing.Imaging.EncoderParameter([System.Drawing.Imaging.Encoder]::Quality, 95)
|
||||
|
||||
# Save as JPG
|
||||
$bitmap.Save($DestinationPath, $jpegCodec, $encoderParams)
|
||||
|
||||
# Cleanup
|
||||
$graphics.Dispose()
|
||||
$bitmap.Dispose()
|
||||
$image.Dispose()
|
||||
$encoderParams.Dispose()
|
||||
|
||||
return $true
|
||||
} catch {
|
||||
Write-Warning "Failed to convert image: $SourcePath - $($_.Exception.Message)"
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# Function to check if image is 16x16 (for FlatColors)
|
||||
function Test-ImageSize {
|
||||
param([string]$ImagePath)
|
||||
|
||||
try {
|
||||
$image = [System.Drawing.Image]::FromFile($ImagePath)
|
||||
$is16x16 = ($image.Width -eq 16 -and $image.Height -eq 16)
|
||||
$image.Dispose()
|
||||
return $is16x16
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# PASS 1: Intra-Blendfile Processing
|
||||
# ============================================================================
|
||||
@@ -419,20 +497,34 @@ if ($null -eq $remainingFiles -or $remainingFiles.Count -eq 0) {
|
||||
$pass2Duplicates += $result.DuplicateCount
|
||||
}
|
||||
|
||||
# Process FlatColors files: merge duplicates and move to \common\FlatColors
|
||||
Write-Host "Processing FlatColors files (merging duplicates)..." -ForegroundColor Yellow
|
||||
# Process FlatColors files: standardize to 16x16 JPG (except TGA), merge duplicates by color code
|
||||
Write-Host "Processing FlatColors files (standardizing and merging duplicates)..." -ForegroundColor Yellow
|
||||
|
||||
if ($null -ne $flatColorsFiles -and $flatColorsFiles.Count -gt 0) {
|
||||
Write-Host "Found $($flatColorsFiles.Count) FlatColors file(s) to process" -ForegroundColor Gray
|
||||
|
||||
# Calculate checksums for FlatColors files
|
||||
Write-Host "Calculating checksums for FlatColors files..." -ForegroundColor Yellow
|
||||
$flatColorsWithChecksums = Get-FilesWithChecksums -Files $flatColorsFiles
|
||||
# Group files by normalized color code (instead of checksum)
|
||||
Write-Host "Grouping FlatColors files by color code..." -ForegroundColor Yellow
|
||||
$filesByColor = @{}
|
||||
|
||||
# Group by checksum to find duplicates
|
||||
$flatColorsGroupedByChecksum = $flatColorsWithChecksums | Group-Object -Property Hash
|
||||
foreach ($file in $flatColorsFiles) {
|
||||
if (-not (Test-Path -Path $file.FullName)) {
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Host "Found $($flatColorsGroupedByChecksum.Count) unique FlatColors file(s)" -ForegroundColor Gray
|
||||
$colorCode = Get-NormalizedColorCode -FileName $file.Name
|
||||
if ($null -eq $colorCode) {
|
||||
Write-Warning "Could not extract color code from: $($file.Name)"
|
||||
continue
|
||||
}
|
||||
|
||||
if (-not $filesByColor.ContainsKey($colorCode)) {
|
||||
$filesByColor[$colorCode] = @()
|
||||
}
|
||||
$filesByColor[$colorCode] += $file
|
||||
}
|
||||
|
||||
Write-Host "Found $($filesByColor.Count) unique color code(s)" -ForegroundColor Gray
|
||||
|
||||
# Create \textures\common\FlatColors directory
|
||||
$flatColorsPath = Join-Path -Path $rootCommonPath -ChildPath "FlatColors"
|
||||
@@ -445,64 +537,185 @@ if ($null -eq $remainingFiles -or $remainingFiles.Count -eq 0) {
|
||||
$filesInFlatColors = @{}
|
||||
$flatColorsMoved = 0
|
||||
$flatColorsDuplicates = 0
|
||||
$flatColorsConverted = 0
|
||||
$flatColorsResized = 0
|
||||
$flatColorsMoveLog = [System.Collections.ArrayList]::new()
|
||||
|
||||
foreach ($group in $flatColorsGroupedByChecksum) {
|
||||
$files = $group.Group
|
||||
foreach ($colorCode in $filesByColor.Keys) {
|
||||
$files = $filesByColor[$colorCode]
|
||||
|
||||
if ($files.Count -eq 1) {
|
||||
# Single file - move to FlatColors folder
|
||||
$fileObj = $files[0].File
|
||||
$fileName = $fileObj.Name
|
||||
# Find the best file to keep (prefer existing JPG, then TGA, then others)
|
||||
$fileToKeep = $null
|
||||
$targetExtension = ".jpg"
|
||||
$targetFileName = "$colorCode.jpg"
|
||||
|
||||
# Strip blendfile prefix if present
|
||||
$strippedName = Get-FileNameWithoutPrefix -FileName $fileName -ValidPrefixes $validBlendfilePrefixes
|
||||
if ($strippedName -ne $fileName) {
|
||||
$fileName = $strippedName
|
||||
# First, check if there's already a correct file in target location
|
||||
$existingTarget = Join-Path -Path $flatColorsPath -ChildPath $targetFileName
|
||||
if (Test-Path -Path $existingTarget) {
|
||||
$existingFile = Get-Item -Path $existingTarget
|
||||
# Check if it's already correct
|
||||
if ($existingFile.Extension -eq ".jpg" -and (Test-ImageSize -ImagePath $existingFile.FullName)) {
|
||||
$fileToKeep = $existingFile
|
||||
}
|
||||
}
|
||||
|
||||
$destinationPath = Join-Path -Path $flatColorsPath -ChildPath $fileName
|
||||
# If no existing correct file, find best source file
|
||||
if ($null -eq $fileToKeep) {
|
||||
# Prefer existing JPG file
|
||||
$jpgFile = $files | Where-Object {
|
||||
($_.Extension -eq ".jpg" -or $_.Extension -eq ".jpeg") -and
|
||||
(Test-Path -Path $_.FullName)
|
||||
} | Select-Object -First 1
|
||||
|
||||
# Handle name conflicts (shouldn't happen for unique files, but just in case)
|
||||
if ($filesInFlatColors.ContainsKey($fileName) -or (Test-Path -Path $destinationPath)) {
|
||||
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($fileName)
|
||||
$extension = [System.IO.Path]::GetExtension($fileName)
|
||||
$counter = 1
|
||||
do {
|
||||
$newFileName = "${baseName}_${counter}${extension}"
|
||||
$destinationPath = Join-Path -Path $flatColorsPath -ChildPath $newFileName
|
||||
$counter++
|
||||
} while ($filesInFlatColors.ContainsKey($newFileName) -or (Test-Path -Path $destinationPath))
|
||||
$fileName = $newFileName
|
||||
if ($jpgFile) {
|
||||
$fileToKeep = $jpgFile
|
||||
} else {
|
||||
# If no JPG, prefer TGA
|
||||
$tgaFile = $files | Where-Object {
|
||||
$_.Extension -eq ".tga" -and
|
||||
(Test-Path -Path $_.FullName)
|
||||
} | Select-Object -First 1
|
||||
|
||||
if ($tgaFile) {
|
||||
$fileToKeep = $tgaFile
|
||||
$targetExtension = ".tga"
|
||||
$targetFileName = "$colorCode.tga"
|
||||
} else {
|
||||
# Otherwise, use the first available file
|
||||
$fileToKeep = $files | Where-Object { Test-Path -Path $_.FullName } | Select-Object -First 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null -eq $fileToKeep) {
|
||||
Write-Warning " ${colorCode}: No valid file found to process"
|
||||
continue
|
||||
}
|
||||
|
||||
$targetPath = Join-Path -Path $flatColorsPath -ChildPath $targetFileName
|
||||
|
||||
# If target is TGA, preserve as-is (don't convert)
|
||||
if ($targetExtension -eq ".tga") {
|
||||
if ($fileToKeep.FullName -ne $targetPath) {
|
||||
# Move TGA to target location
|
||||
try {
|
||||
$originalPath = $fileObj.FullName
|
||||
Move-Item -Path $originalPath -Destination $destinationPath -Force
|
||||
$filesInFlatColors[$fileName] = $true
|
||||
if (Test-Path -Path $targetPath) {
|
||||
Remove-Item -Path $targetPath -Force
|
||||
}
|
||||
$originalPath = $fileToKeep.FullName
|
||||
Move-Item -Path $originalPath -Destination $targetPath -Force
|
||||
$filesInFlatColors[$targetFileName] = $true
|
||||
$flatColorsMoved++
|
||||
|
||||
# Log the move
|
||||
$normalizedOriginal = [System.IO.Path]::GetFullPath($originalPath)
|
||||
$normalizedNew = [System.IO.Path]::GetFullPath($destinationPath)
|
||||
$normalizedNew = [System.IO.Path]::GetFullPath($targetPath)
|
||||
$null = $flatColorsMoveLog.Add([PSCustomObject]@{
|
||||
OriginalPath = $normalizedOriginal
|
||||
NewPath = $normalizedNew
|
||||
Type = "moved"
|
||||
})
|
||||
} catch {
|
||||
Write-Warning "Failed to move FlatColors file: $($fileObj.FullName) - $($_.Exception.Message)"
|
||||
Write-Warning " ${colorCode}: Failed to move TGA: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Multiple files with same checksum (duplicates) - merge them
|
||||
# Use Process-DuplicateGroup to handle merging
|
||||
$result = Process-DuplicateGroup -Files $files -CommonPath $flatColorsPath -FilesInCommon $filesInFlatColors -StripPrefix -ValidPrefixes $validBlendfilePrefixes -MoveLog $flatColorsMoveLog
|
||||
$flatColorsMoved += $result.MovedCount
|
||||
$flatColorsDuplicates += $result.DuplicateCount
|
||||
# Target is JPG - convert/resize if needed
|
||||
$needsConversion = $false
|
||||
$needsResize = $false
|
||||
|
||||
if ($fileToKeep.Extension -ne ".jpg" -and $fileToKeep.Extension -ne ".jpeg") {
|
||||
$needsConversion = $true
|
||||
}
|
||||
|
||||
if (-not (Test-ImageSize -ImagePath $fileToKeep.FullName)) {
|
||||
$needsResize = $true
|
||||
}
|
||||
|
||||
# Check if target already exists and is correct
|
||||
if ((Test-Path -Path $targetPath) -and
|
||||
(Get-Item -Path $targetPath).Extension -eq ".jpg" -and
|
||||
(Test-ImageSize -ImagePath $targetPath)) {
|
||||
# Target already exists and is correct, skip
|
||||
} elseif ($needsConversion -or $needsResize -or $fileToKeep.FullName -ne $targetPath) {
|
||||
# Convert/resize to target
|
||||
if (Convert-To16x16Jpg -SourcePath $fileToKeep.FullName -DestinationPath $targetPath) {
|
||||
if ($needsConversion -and $needsResize) {
|
||||
$flatColorsConverted++
|
||||
$flatColorsResized++
|
||||
} elseif ($needsConversion) {
|
||||
$flatColorsConverted++
|
||||
} elseif ($needsResize) {
|
||||
$flatColorsResized++
|
||||
} else {
|
||||
$flatColorsMoved++
|
||||
}
|
||||
|
||||
$filesInFlatColors[$targetFileName] = $true
|
||||
|
||||
# Log the conversion/move
|
||||
$normalizedOriginal = [System.IO.Path]::GetFullPath($fileToKeep.FullName)
|
||||
$normalizedNew = [System.IO.Path]::GetFullPath($targetPath)
|
||||
$null = $flatColorsMoveLog.Add([PSCustomObject]@{
|
||||
OriginalPath = $normalizedOriginal
|
||||
NewPath = $normalizedNew
|
||||
Type = "moved"
|
||||
})
|
||||
} else {
|
||||
Write-Warning " ${colorCode}: Failed to convert/resize"
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
# File is already correct format and size
|
||||
if ($fileToKeep.FullName -ne $targetPath) {
|
||||
try {
|
||||
if (Test-Path -Path $targetPath) {
|
||||
Remove-Item -Path $targetPath -Force
|
||||
}
|
||||
$originalPath = $fileToKeep.FullName
|
||||
Move-Item -Path $originalPath -Destination $targetPath -Force
|
||||
$filesInFlatColors[$targetFileName] = $true
|
||||
$flatColorsMoved++
|
||||
|
||||
# Log the move
|
||||
$normalizedOriginal = [System.IO.Path]::GetFullPath($originalPath)
|
||||
$normalizedNew = [System.IO.Path]::GetFullPath($targetPath)
|
||||
$null = $flatColorsMoveLog.Add([PSCustomObject]@{
|
||||
OriginalPath = $normalizedOriginal
|
||||
NewPath = $normalizedNew
|
||||
Type = "moved"
|
||||
})
|
||||
} catch {
|
||||
Write-Warning " ${colorCode}: Failed to move: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Moved $flatColorsMoved unique FlatColors file(s) to \common\FlatColors, deleted $flatColorsDuplicates duplicate(s)" -ForegroundColor Green
|
||||
# Delete duplicate files (all files in the group except the target)
|
||||
foreach ($file in $files) {
|
||||
if ($file.FullName -ne $targetPath -and (Test-Path -Path $file.FullName)) {
|
||||
try {
|
||||
$originalPath = $file.FullName
|
||||
Remove-Item -Path $originalPath -Force
|
||||
$flatColorsDuplicates++
|
||||
|
||||
# Log the deletion
|
||||
$normalizedOriginal = [System.IO.Path]::GetFullPath($originalPath)
|
||||
$normalizedReplacement = [System.IO.Path]::GetFullPath($targetPath)
|
||||
$null = $flatColorsMoveLog.Add([PSCustomObject]@{
|
||||
OriginalPath = $normalizedOriginal
|
||||
ReplacedBy = $normalizedReplacement
|
||||
Type = "deleted"
|
||||
})
|
||||
} catch {
|
||||
Write-Warning " Failed to delete duplicate: $($file.FullName) - $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Processed FlatColors: $flatColorsMoved moved, $flatColorsConverted converted, $flatColorsResized resized, $flatColorsDuplicates duplicate(s) deleted" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "No FlatColors files found to process." -ForegroundColor Gray
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user