updateseq fix rename?

This commit is contained in:
Nathan
2025-11-06 14:38:35 -07:00
parent ded87cdc68
commit eab3e22bbe
3 changed files with 1317 additions and 11 deletions

View File

@@ -1914,6 +1914,893 @@ Output mode: content
---
<think><details><summary>Thought Process</summary>
**Enhancing sequence handling to exclude _archive directories**
Im planning to update sequence-related functions to fully ignore any folders named `_archive`. This involves adjusting directory walking methods to skip `_archive` both when finding sequences and when zipping files, using path checks and filtering the directory names to avoid recursion into those folders. For consistency, Ill also replace top-level iteration with recursive walks that apply these filters, ensuring zipped archives and computed states exclude any `_archive` contents. Adding helper functions to detect `_archive` in paths will keep things clean and reusable. Next, Ill implement these changes to make sequence processing reliably skip archived data.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: zip_sequences.py</summary>
**Chunk 1**
Lines added: 18, lines removed: 4
```diff
@@ -59,23 +59,37 @@
print(f&quot;[{mode}] {message}&quot;)
+
+ def is_archive_path(path: Path) -&gt; bool:
+ return any(part == &quot;_archive&quot; for part in path.parts)
+
def find_sequence_dirs(root: Path) -&gt; Iterator[Path]:
for dirpath, dirnames, filenames in os.walk(root):
path = Path(dirpath)
- if ARCHIVE_ROOT in path.parents or path == ARCHIVE_ROOT:
- dirnames.clear()
+ dirnames[:] = [d for d in dirnames if d != &quot;_archive&quot;]
+ if is_archive_path(path):
continue
has_frames = any(Path(dirpath, f).suffix.lower() in SEQUENCE_EXTENSIONS for f in filenames)
if has_frames:
yield path
+
+ def iter_sequence_files(seq_dir: Path) -&gt; Iterator[Path]:
+ for dirpath, dirnames, filenames in os.walk(seq_dir):
+ path = Path(dirpath)
+ dirnames[:] = [d for d in dirnames if d != &quot;_archive&quot;]
+ if is_archive_path(path):
+ continue
+ for filename in filenames:
+ yield path / filename
+
def compute_state(seq_dir: Path) -&gt; dict:
entries = []
- for file_path in sorted(p for p in seq_dir.iterdir() if p.is_file()):
+ for file_path in sorted(iter_sequence_files(seq_dir), key=lambda p: p.relative_to(seq_dir)):
stat = file_path.stat()
entries.append(
{
- &quot;path&quot;: file_path.name,
+ &quot;path&quot;: str(file_path.relative_to(seq_dir)),
&quot;size&quot;: stat.st_size,
&quot;mtime_ns&quot;: stat.st_mtime_ns,
```
**Chunk 2**
Lines added: 2, lines removed: 4
```diff
@@ -125,8 +139,6 @@
zip_path.parent.mkdir(parents=True, exist_ok=True)
with ZipFile(zip_path, &quot;w&quot;, compression=ZIP_STORED) as archive:
- for file_path in sorted(seq_dir.iterdir()):
- if not file_path.is_file():
- continue
- archive.write(file_path, arcname=file_path.name)
+ for file_path in iter_sequence_files(seq_dir):
+ archive.write(file_path, arcname=str(file_path.relative_to(seq_dir)))
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Standardizing file path handling**
I'm updating how file paths are recorded and processed to consistently use relative POSIX-style paths across state computations, zip archive processing, and sequence expansions—ensuring compatibility across OSes and existing metadata formats while adjusting directory traversal to properly exclude `_archive` folders without disrupting walk behavior.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: zip_sequences.py</summary>
**Chunk 1**
Lines added: 6, lines removed: 2
```diff
@@ -87,9 +87,13 @@
def compute_state(seq_dir: Path) -&gt; dict:
entries = []
- for file_path in sorted(iter_sequence_files(seq_dir), key=lambda p: p.relative_to(seq_dir)):
+ files = sorted(
+ iter_sequence_files(seq_dir),
+ key=lambda p: p.relative_to(seq_dir).as_posix(),
+ )
+ for file_path in files:
stat = file_path.stat()
entries.append(
{
- &quot;path&quot;: str(file_path.relative_to(seq_dir)),
+ &quot;path&quot;: file_path.relative_to(seq_dir).as_posix(),
&quot;size&quot;: stat.st_size,
&quot;mtime_ns&quot;: stat.st_mtime_ns,
```
**Chunk 2**
Lines added: 1, lines removed: 1
```diff
@@ -140,5 +144,5 @@
with ZipFile(zip_path, &quot;w&quot;, compression=ZIP_STORED) as archive:
for file_path in iter_sequence_files(seq_dir):
- archive.write(file_path, arcname=str(file_path.relative_to(seq_dir)))
+ archive.write(file_path, arcname=file_path.relative_to(seq_dir).as_posix())
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Adjusting path handling and test setup**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "md tmp_proj_test\Renders\daily_0001\_archive 2>nul"</summary>
```bash
cmd /c "md tmp_proj_test\Renders\daily_0001\_archive 2>nul"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Preparing sample files**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "echo dummy> tmp_proj_test\Renders\daily_0001\frame_000001.png"</summary>
```bash
cmd /c "echo dummy> tmp_proj_test\Renders\daily_0001\frame_000001.png"
```
</details>
</tool-use>
---
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "echo should_ignore> tmp_proj_test\Renders\daily_0001\_archive\old_000001.png"</summary>
```bash
cmd /c "echo should_ignore> tmp_proj_test\Renders\daily_0001\_archive\old_000001.png"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Updating location to Renders**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "cd /d tmp_proj_test\Renders && ..\..\ZipSeqArchv.bat"</summary>
```bash
cmd /c "cd /d tmp_proj_test\Renders && ..\..\ZipSeqArchv.bat"
```
```
&#39;..\..\ZipSeqArchv.bat&#39; is not recognized as an internal or external command,
operable program or batch file.
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Preparing to copy script for testing**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\ZipSeqArchv.bat</summary>
```bash
Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\ZipSeqArchv.bat
```
```
Copy-Item : Cannot find path &#39;C:\Users\Nathan\ZipSeqArchv.bat&#39; because it does not exist.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-322bc1a8-adfa-43be-9bfd-07edab7e6c26.ps1:77 char:1
+ Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\ZipSeqArchv.bat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\Nathan\ZipSeqArchv.bat:String) [Copy-Item], ItemNotFoundExcept
ion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Specifying full path for Copy-Item**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item .\ZipSeqArchv.bat .\tmp_proj_test\Renders\</summary>
```bash
Copy-Item .\ZipSeqArchv.bat .\tmp_proj_test\Renders\
```
```
Copy-Item : Cannot find path &#39;C:\Users\Nathan\ZipSeqArchv.bat&#39; because it does not exist.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-04bc7d3c-7493-4844-97c9-8020d044885d.ps1:77 char:1
+ Copy-Item .\ZipSeqArchv.bat .\tmp_proj_test\Renders\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\Nathan\ZipSeqArchv.bat:String) [Copy-Item], ItemNotFoundExcept
ion
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Resetting PowerShell directory**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"</summary>
```bash
Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Rerunning the copy command**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\</summary>
```bash
Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\
```
```
Copy-Item : The filename, directory name, or volume label syntax is incorrect.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-b2fc8193-6ce1-4d42-8b6a-dd13b2974322.ps1:77 char:1
+ Copy-Item ZipSeqArchv.bat tmp_proj_test\Renders\
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Handling paths with spaces**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item "ZipSeqArchv.bat" "tmp_proj_test\Renders\"</summary>
```bash
Copy-Item "ZipSeqArchv.bat" "tmp_proj_test\Renders\"
```
```
Copy-Item : The filename, directory name, or volume label syntax is incorrect.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-f0967402-2d8c-46c4-9fdf-c1cd85d01021.ps1:77 char:1
+ Copy-Item &quot;ZipSeqArchv.bat&quot; &quot;tmp_proj_test\Renders\&quot;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Troubleshooting path handling with Copy-Item**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Copy-Item -LiteralPath "A:\1 Amazon_Active_Projects\3 ProjectStructure\ZipSeqArchv.bat" -Destination "A:\1 Amazon_Active_Projects\3 ProjectStructure\tmp_proj_test\Renders\ZipSeqArchv.bat" -Force</summary>
```bash
Copy-Item -LiteralPath "A:\1 Amazon_Active_Projects\3 ProjectStructure\ZipSeqArchv.bat" -Destination "A:\1 Amazon_Active_Projects\3 ProjectStructure\tmp_proj_test\Renders\ZipSeqArchv.bat" -Force
```
```
Copy-Item : Could not find a part of the path &#39;A:\1 Amazon_Active_Projects\3
ProjectStructure\tmp_proj_test\Renders\ZipSeqArchv.bat&#39;.
At C:\Users\Nathan\AppData\Local\Temp\ps-script-a25e5da6-d918-4cf9-b98a-a3b8baf0842b.ps1:77 char:1
+ Copy-Item -LiteralPath &quot;A:\1 Amazon_Active_Projects\3 ProjectStructur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Checking existence of tmp_proj_test**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem</summary>
```bash
Get-ChildItem
```
```
Directory: A:\1 Amazon_Active_Projects\3 ProjectStructure
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/30/2025 11:25 AM components
d----- 10/10/2025 3:30 PM scripts_old
-a---- 11/6/2025 10:51 AM 486 ZipSeqArchv.bat
------ 10/29/2025 12:47 PM 16755 replace_cel_with_bsdf.py
------ 9/11/2025 3:51 PM 4990 remove_action_fake_users.bat
------ 10/29/2025 12:47 PM 2606 UpgradeSeqBatches.ps1
------ 8/15/2025 12:06 PM 775 outline.txt
-a---- 11/6/2025 10:32 AM 9059 UpgradeToGitProj.bat
-a---- 11/6/2025 10:51 AM 500 UnzipSeqArchv.bat
-a---- 11/6/2025 12:07 PM 10311 zip_sequences.py
-a---- 11/6/2025 10:32 AM 8947 UpdateSequences.ps1
------ 9/17/2025 1:52 PM 5757 compress_blend_files.bat
------ 10/29/2025 12:47 PM 298 NewDaily.bat
-a---- 11/6/2025 10:45 AM 2382 NewProject.bat
------ 10/30/2025 5:14 PM 321 UpdateSequences.bat
------ 8/26/2025 3:57 PM 1657 UpdateAllSequences.bat
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Preparing to recreate missing project directory**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: cmd /c "md tmp_proj_test\Renders"</summary>
```bash
cmd /c "md tmp_proj_test\Renders"
```
</details>
</tool-use>
---
_**User (2025-11-06 21:23Z)**_
@UpdateSequences.ps1 it's not renaming them properly. Look how @ `A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1` are all named _CURRENT
---
_**Agent (model gpt-5-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Adjusting sequence renaming logic for _CURRENT folders**
I'm working through changing the UpdateSequences.ps1 script so that when it encounters a folder named `_CURRENT`, it uses the parent folders name for renaming sequences instead of `_CURRENT`. This involves building a sequence list with custom objects holding both path and effective sequence name, plus helper functions to resolve the right sequence name by climbing up from `_CURRENT` folders. The goal is to rename files according to their containing folder rather than `_CURRENT`, fixing issues where files were incorrectly prefixed with `_CURRENT`. I'll also ensure lists avoid duplicates and update loops to work with these objects. This should clarify the naming and better reflect the current folder structure.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: UpdateSequences.ps1</summary>
**Chunk 1**
Lines added: 26, lines removed: undefined
```diff
@@ -136,4 +136,30 @@
}
}
+
+ function Resolve-SequenceName {
+ param(
+ [Parameter(Mandatory)] [System.IO.DirectoryInfo]$Directory
+ )
+ if ($Directory.Name -eq &#39;_CURRENT&#39; -and $Directory.Parent) {
+ return $Directory.Parent.Name
+ }
+ return $Directory.Name
+ }
+
+ function Add-SequenceFolder {
+ param(
+ [Parameter(Mandatory)] [System.IO.DirectoryInfo]$Directory,
+ [Parameter(Mandatory)] [hashtable]$Seen,
+ [Parameter(Mandatory)] [System.Collections.ArrayList]$Collector
+ )
+ if ($Directory.Name -eq &#39;_archive&#39;) { return }
+ $fullPath = $Directory.FullName
+ if ($Seen.ContainsKey($fullPath)) { return }
+ $Seen[$fullPath] = $true
+ $null = $Collector.Add([pscustomobject]@{
+ Path = $fullPath
+ Name = Resolve-SequenceName -Directory $Directory
+ })
+ }
try {
```
**Chunk 2**
Lines added: 1, lines removed: undefined
```diff
@@ -147,4 +173,5 @@
$sequenceFolders = @()
+ $sequenceMap = @{}
$dailyDirs = Get-ChildItem -LiteralPath $root -Directory -Filter &#39;daily_*&#39; -ErrorAction SilentlyContinue |
```
**Chunk 3**
Lines added: 8, lines removed: 4
```diff
@@ -153,15 +180,19 @@
$seqDirs = @(Get-ChildItem -LiteralPath $d.FullName -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ne &#39;_archive&#39; })
if ($seqDirs.Count -eq 0) {
- $sequenceFolders += $d
+ Add-SequenceFolder -Directory $d -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
} else {
- $sequenceFolders += $seqDirs
+ foreach ($s in $seqDirs) {
+ Add-SequenceFolder -Directory $s -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
+ }
}
}
$directSeqs = Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -ne &#39;_archive&#39; -and $_.Name -notlike &#39;daily_*&#39; }
- $sequenceFolders += $directSeqs
+ foreach ($seq in $directSeqs) {
+ Add-SequenceFolder -Directory $seq -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
+ }
- $sequenceFolders = $sequenceFolders | Sort-Object -Property FullName -Unique
+ $sequenceFolders = $sequenceFolders | Sort-Object -Property Path
if (-not $sequenceFolders) {
```
**Chunk 4**
Lines added: 2, lines removed: 2
```diff
@@ -181,7 +212,7 @@
foreach ($seq in $sequenceFolders) {
$totalSequences++
- $renameResult = Sync-SequenceFilenames -SequenceFolderPath $seq.FullName -SequenceName $seq.Name -LogFile $logFile
+ $renameResult = Sync-SequenceFilenames -SequenceFolderPath $seq.Path -SequenceName $seq.Name -LogFile $logFile
if ($DebugMode -or $renameResult.Renamed -gt 0 -or $renameResult.Collisions -gt 0 -or $renameResult.Errors -gt 0) {
- Write-Host &quot;[RENAME]|$($seq.FullName)|$($seq.Name)|checked=$($renameResult.Checked)|renamed=$($renameResult.Renamed)|collisions=$($renameResult.Collisions)|errors=$($renameResult.Errors)&quot; -ForegroundColor Cyan
+ Write-Host &quot;[RENAME]|$($seq.Path)|$($seq.Name)|checked=$($renameResult.Checked)|renamed=$($renameResult.Renamed)|collisions=$($renameResult.Collisions)|errors=$($renameResult.Errors)&quot; -ForegroundColor Cyan
}
$filesRenamedTotal += $renameResult.Renamed
```
**Chunk 5**
Lines added: 2, lines removed: 2
```diff
@@ -190,7 +221,7 @@
if ($renameResult.FrameCount -gt 0 -and $renameResult.MinFrame -ne $null -and $renameResult.MaxFrame -ne $null) {
- $mp4Result = Rename-SequencePreviewMp4 -SequenceFolderPath $seq.FullName -SequenceName $seq.Name -StartFrame $renameResult.MinFrame -EndFrame $renameResult.MaxFrame -LogFile $logFile
+ $mp4Result = Rename-SequencePreviewMp4 -SequenceFolderPath $seq.Path -SequenceName $seq.Name -StartFrame $renameResult.MinFrame -EndFrame $renameResult.MaxFrame -LogFile $logFile
if ($DebugMode -or $mp4Result.Renamed -gt 0 -or $mp4Result.Collisions -gt 0 -or $mp4Result.Errors -gt 0) {
- Write-Host &quot;[MP4]|$($seq.FullName)|$($seq.Name)|renamed=$($mp4Result.Renamed)|collisions=$($mp4Result.Collisions)|errors=$($mp4Result.Errors)&quot; -ForegroundColor Cyan
+ Write-Host &quot;[MP4]|$($seq.Path)|$($seq.Name)|renamed=$($mp4Result.Renamed)|collisions=$($mp4Result.Collisions)|errors=$($mp4Result.Errors)&quot; -ForegroundColor Cyan
}
$mp4RenamedTotal += $mp4Result.Renamed
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Refactoring sequenceFolders handling**
I'm switching from using `[ref]` with arrays to managing `$sequenceFolders` as a `System.Collections.ArrayList`, which allows adding items dynamically. I'll update the `Add-SequenceFolder` function to accept and manipulate this ArrayList directly, and handle sorting later by converting it to a normal array. This approach should fix issues with fixed-size arrays and simplify the collector parameter usage.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: UpdateSequences.ps1</summary>
**Chunk 1**
Lines added: 1, lines removed: 1
```diff
@@ -172,5 +172,5 @@
}
- $sequenceFolders = @()
+ $sequenceFolders = New-Object System.Collections.ArrayList
$sequenceMap = @{}
```
**Chunk 2**
Lines added: 2, lines removed: 2
```diff
@@ -180,8 +180,8 @@
$seqDirs = @(Get-ChildItem -LiteralPath $d.FullName -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ne &#39;_archive&#39; })
if ($seqDirs.Count -eq 0) {
- Add-SequenceFolder -Directory $d -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
+ Add-SequenceFolder -Directory $d -Seen $sequenceMap -Collector $sequenceFolders
} else {
foreach ($s in $seqDirs) {
- Add-SequenceFolder -Directory $s -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
+ Add-SequenceFolder -Directory $s -Seen $sequenceMap -Collector $sequenceFolders
}
}
```
**Chunk 3**
Lines added: 1, lines removed: 1
```diff
@@ -191,5 +191,5 @@
Where-Object { $_.Name -ne &#39;_archive&#39; -and $_.Name -notlike &#39;daily_*&#39; }
foreach ($seq in $directSeqs) {
- Add-SequenceFolder -Directory $seq -Seen $sequenceMap -Collector ([ref]$sequenceFolders).Value
+ Add-SequenceFolder -Directory $seq -Seen $sequenceMap -Collector $sequenceFolders
}
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Ensuring helper function consistency**</details></think>
---
- `updateSequences.ps1` now derives the file prefix from the nearest non-`_CURRENT` folder so frames under directories like `...Renders\Associate_TT_animation 1\_CURRENT\` are renamed to `Associate_TT_animation 1_*.png` rather than `_CURRENT_*.png`; the discovery pass also deduplicates paths with an ArrayList + map.
```144:195:UpdateSequences.ps1
function Resolve-SequenceName {
if ($Directory.Name -eq '_CURRENT' -and $Directory.Parent) { return $Directory.Parent.Name }
return $Directory.Name
}
function Add-SequenceFolder { … $Collector.Add([pscustomobject]@{ Path = $fullPath; Name = Resolve-SequenceName -Directory $Directory }) }
$sequenceFolders = New-Object System.Collections.ArrayList
Add-SequenceFolder -Directory $s …
foreach ($seq in $sequenceFolders) {
$renameResult = Sync-SequenceFilenames -SequenceFolderPath $seq.Path -SequenceName $seq.Name …
```
- `zip_sequences.py` skips `_archive` trees when hashing or archiving (files stored with POSIX relative paths), so old renders arent packed.
```62:119:zip_sequences.py
def is_archive_path(path: Path) -> bool:
return any(part == "_archive" for part in path.parts)
def find_sequence_dirs(root: Path): … dirnames[:] = [d for d in dirnames if d != "_archive"]
def iter_sequence_files(seq_dir: Path): … yields files excluding `_archive`
def compute_state(seq_dir: Path): entries append {"path": file_path.relative_to(seq_dir).as_posix(), …}
def zip_sequence(...):
for file_path in iter_sequence_files(seq_dir):
archive.write(file_path, arcname=file_path.relative_to(seq_dir).as_posix())
```
- `ZipSeqArchv.bat` / `UnzipSeqArchv.bat` now `pushd` the project root (parent of the `Renders` folder) before calling Python, so they work when launched from the copied location.
---
_**User (2025-11-06 21:23Z)**_
Running PowerShell update script...
ERROR: Cannot bind argument to parameter 'Collector' because it is an empty collection.
PowerShell exited with RC=1
Done.
---
_**Agent (model gpt-5-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Investigating parameter binding error in PowerShell script**</details></think>
---
<tool-use data-tool-type="read" data-tool-name="read_file">
<details><summary>Tool use: **read_file** • Read file: UpdateSequences.ps1</summary>
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Refactoring collection handling to avoid binding errors**
Im rethinking how the script manages sequence folders by removing the collection parameter that causes binder errors when empty; instead, Ill store data in a hashtable during traversal and build the final sorted collection afterward, simplifying the flow and sidestepping issues with typed empty collections.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: UpdateSequences.ps1</summary>
**Chunk 1**
Lines added: 3, lines removed: 8
```diff
@@ -150,15 +150,10 @@
param(
[Parameter(Mandatory)] [System.IO.DirectoryInfo]$Directory,
- [Parameter(Mandatory)] [hashtable]$Seen,
- [Parameter(Mandatory)] [System.Collections.ArrayList]$Collector
+ [Parameter(Mandatory)] [hashtable]$Map
)
if ($Directory.Name -eq &#39;_archive&#39;) { return }
$fullPath = $Directory.FullName
- if ($Seen.ContainsKey($fullPath)) { return }
- $Seen[$fullPath] = $true
- $null = $Collector.Add([pscustomobject]@{
- Path = $fullPath
- Name = Resolve-SequenceName -Directory $Directory
- })
+ if ($Map.ContainsKey($fullPath)) { return }
+ $Map[$fullPath] = Resolve-SequenceName -Directory $Directory
}
```
**Chunk 2**
Lines added: undefined, lines removed: 1
```diff
@@ -172,5 +167,4 @@
}
- $sequenceFolders = New-Object System.Collections.ArrayList
$sequenceMap = @{}
```
**Chunk 3**
Lines added: 2, lines removed: 2
```diff
@@ -180,8 +174,8 @@
$seqDirs = @(Get-ChildItem -LiteralPath $d.FullName -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ne &#39;_archive&#39; })
if ($seqDirs.Count -eq 0) {
- Add-SequenceFolder -Directory $d -Seen $sequenceMap -Collector $sequenceFolders
+ Add-SequenceFolder -Directory $d -Map $sequenceMap
} else {
foreach ($s in $seqDirs) {
- Add-SequenceFolder -Directory $s -Seen $sequenceMap -Collector $sequenceFolders
+ Add-SequenceFolder -Directory $s -Map $sequenceMap
}
}
```
**Chunk 4**
Lines added: 7, lines removed: 2
```diff
@@ -191,8 +185,13 @@
Where-Object { $_.Name -ne &#39;_archive&#39; -and $_.Name -notlike &#39;daily_*&#39; }
foreach ($seq in $directSeqs) {
- Add-SequenceFolder -Directory $seq -Seen $sequenceMap -Collector $sequenceFolders
+ Add-SequenceFolder -Directory $seq -Map $sequenceMap
}
- $sequenceFolders = $sequenceFolders | Sort-Object -Property Path
+ $sequenceFolders = $sequenceMap.GetEnumerator() | ForEach-Object {
+ [pscustomobject]@{
+ Path = $_.Key
+ Name = $_.Value
+ }
+ } | Sort-Object -Property Path
if (-not $sequenceFolders) {
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Preparing response with lint instructions**</details></think>
---
Looks like the error was coming from the new `Add-SequenceFolder` helper expecting a concrete `ArrayList`. I reworked the aggregation so it now writes straight into a hashtable and builds the final folder list afterward. You shouldnt see the “empty collection” binding failure anymore. Give `UpdateSequences.ps1` another run (same command you just used) and it should proceed, renaming `_CURRENT` frames using their parent folder name.
---
_**User (2025-11-06 21:23Z)**_
they're all still named _CURRENT
---
_**Agent (model gpt-5-codex, mode Agent)**_
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" | Select-Object -First 5</summary>
```bash
Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" | Select-Object -First 5
```
```
Directory: A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/5/2025 2:22 PM 3576191 _CURRENT_000216.png
-a---- 11/5/2025 2:21 PM 3571930 _CURRENT_000101.png
-a---- 11/5/2025 2:25 PM 3595645 _CURRENT_000438.png
-a---- 11/5/2025 5:06 PM 3568915 Associate_TT_animation 1_000035.png
-a---- 11/5/2025 2:22 PM 3586147 _CURRENT_000059.png
```
</details>
</tool-use>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -File | Select-Object -First 10 | Format-Table Name</summary>
```bash
Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -File | Select-Object -First 10 | Format-Table Name
```
```
Name
----
_CURRENT_000216.png
_CURRENT_000101.png
_CURRENT_000438.png
Associate_TT_animation 1_000035.png
_CURRENT_000059.png
Associate_TT_animation 1_000454.png
Associate_TT_animation 1_000322.png
_CURRENT_000088.png
Associate_TT_animation 1_000485.png
Associate_TT_animation 1_000206.png
```
</details>
</tool-use>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Directory</summary>
```bash
Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Directory
```
</details>
</tool-use>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1\..\UpdateSequences.ps1"</summary>
```bash
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1\..\UpdateSequences.ps1"
```
```
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
The argument &#39;A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1\..\UpdateSequences.ps1&#39; to the -File parameter does not exist. Provide the path to an existing &#39;.ps1&#39; file as an argument to the -File parameter.
```
</details>
</tool-use>
---
---
_**User (2025-11-06 21:23Z)**_
continue?
---
_**Agent (model gpt-5-codex, mode Agent)**_
---

View File

@@ -0,0 +1,366 @@
<!-- Generated by SpecStory, Markdown v2.0.0 -->
<!-- cursor Session 0660cdc3-12de-4d9b-91e6-ebe52707be1b (2025-11-06 21:32Z) -->
# Continue integration of new elements (2025-11-06 21:32Z)
_**User (2025-11-06 21:32Z)**_
@2025-11-06_17-01Z-integrate-new-elements-and-update-sequences.md continue?
---
_**Agent (model gpt-5-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Reviewing plan continuity and debugging script**</details></think>
---
<tool-use data-tool-type="read" data-tool-name="read_file">
<details><summary>Tool use: **read_file** • Read file: UpdateSequences.ps1</summary>
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Investigating _CURRENT directory presence**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Directory</summary>
```bash
Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Directory
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Analyzing rename collisions with _CURRENT files**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Filter "Associate_TT_animation 1_000059.png"</summary>
```bash
Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -Filter "Associate_TT_animation 1_000059.png"
```
```
Directory: A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/5/2025 5:08 PM 3586526 Associate_TT_animation 1_000059.png
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Handling file rename collisions with archival and deduplication**
I'm thinking through how to handle cases when renamed target files already exist—likely duplicates from previous partial renames involving `_CURRENT` folders. The plan is to compare timestamps and sizes to deduplicate: if files are identical, remove the source `_CURRENT` file; if different, move the existing target to an `_archive` folder (creating it if needed) before renaming the source. This approach keeps only the latest versions per frame, avoids losing data, and ensures no `_CURRENT` files remain after the script runs. I'll integrate this logic carefully, including unique naming in `_archive` to avoid further collisions and adjust counters and logging accordingly.</details></think>
---
<tool-use data-tool-type="write" data-tool-name="edit_file">
<details><summary>Tool use: **code_edit** • Edit file: UpdateSequences.ps1</summary>
**Chunk 1**
Lines added: 25, lines removed: 2
```diff
@@ -59,7 +59,30 @@
try {
if (Test-Path -LiteralPath $newPath) {
+ $existing = Get-Item -LiteralPath $newPath -ErrorAction Stop
+ $sameSize = ($existing.Length -eq $f.Length)
+ $sameTime = ([math]::Abs(($existing.LastWriteTimeUtc - $f.LastWriteTimeUtc).TotalSeconds) -le 1)
+ if ($sameSize -and $sameTime) {
+ Remove-Item -LiteralPath $f.FullName -Force -ErrorAction Stop
+ $collisions++
+ if ($LogFile) { &quot;[$(Get-Date -Format &#39;yyyy-MM-dd HH:mm:ss&#39;)] RENAME DROP duplicate: &#39;$($f.Name)&#39; (matches &#39;$newName&#39;)&quot; | Add-Content -LiteralPath $LogFile }
+ continue
+ }
+
+ $archiveDir = Join-Path $SequenceFolderPath &#39;_archive&#39;
+ if (-not (Test-Path -LiteralPath $archiveDir)) {
+ New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null
+ }
+
+ $archiveName = $existing.Name
+ $archivePath = Join-Path $archiveDir $archiveName
+ if (Test-Path -LiteralPath $archivePath) {
+ $stamp = Get-Date -Format &#39;yyyyMMdd_HHmmss&#39;
+ $baseName = [System.IO.Path]::GetFileNameWithoutExtension($archiveName)
+ $archivePath = Join-Path $archiveDir (&quot;{0}_{1}{2}&quot; -f $baseName, $stamp, $existing.Extension)
+ }
+
+ Move-Item -LiteralPath $existing.FullName -Destination $archivePath -Force -ErrorAction Stop
$collisions++
- if ($LogFile) { &quot;[$(Get-Date -Format &#39;yyyy-MM-dd HH:mm:ss&#39;)] RENAME SKIP collision: &#39;$($f.Name)&#39; -&gt; &#39;$newName&#39;&quot; | Add-Content -LiteralPath $LogFile }
- continue
+ if ($LogFile) { &quot;[$(Get-Date -Format &#39;yyyy-MM-dd HH:mm:ss&#39;)] RENAME ARCHIVE existing &#39;$($existing.Name)&#39; -&gt; &#39;$archivePath&#39;&quot; | Add-Content -LiteralPath $LogFile }
}
Rename-Item -LiteralPath $f.FullName -NewName $newName -ErrorAction Stop
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Verifying archive path handling and script execution**
Im checking how `archivePath` is logged—whether to use the full path or just the name—and confirming that `Move-Item` usage is correct without a `-LiteralPath` option for destination. Im also ensuring date formats are properly quoted and thinking through how to handle filename collisions with `Join-Path`. Next, I plan to run the `UpdateSequences.ps1` script from the appropriate `Renders` folder to confirm everything behaves as expected.</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Set-Location "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders"</summary>
```bash
Set-Location "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Running the script**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File "A:\1 Amazon_Active_Projects\3 ProjectStructure\UpdateSequences.ps1"</summary>
```bash
powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -File "A:\1 Amazon_Active_Projects\3 ProjectStructure\UpdateSequences.ps1"
```
```
[RENAME]|A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1|Associate_TT_animation 1|checked=978|renamed=489|collisions=489|errors=0
[RENAME]|A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 2|Associate_TT_animation 2|checked=722|renamed=0|collisions=360|errors=1
[RENAME]|A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 3|Associate_TT_animation 3|checked=468|renamed=0|collisions=234|errors=0
=== SUMMARY REPORT ===
Sequences scanned: 11
Files renamed: 489 (collisions: 1083, errors: 1)
Preview MP4s renamed: 0 (collisions: 0, errors: 0)
=====================
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Investigating collision handling and renaming**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -File | Select-Object -First 10 | Format-Table Name</summary>
```bash
Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1" -File | Select-Object -First 10 | Format-Table Name
```
```
Name
----
Associate_TT_animation 1_000035.png
Associate_TT_animation 1_000454.png
Associate_TT_animation 1_000322.png
Associate_TT_animation 1_000485.png
Associate_TT_animation 1_000206.png
Associate_TT_animation 1_000111.png
Associate_TT_animation 1_000049.png
Associate_TT_animation 1_000428.png
Associate_TT_animation 1_000098.png
Associate_TT_animation 1_000201.png
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Checking other sequences for _CURRENT**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 2" -File | Select-Object -First 10 | Format-Table Name</summary>
```bash
Get-ChildItem -Path "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 2" -File | Select-Object -First 10 | Format-Table Name
```
```
Name
----
Associate_TT_animation 2_000093.png
Associate_TT_animation 2_000355.png
Associate_TT_animation 2_000384.png
Associate_TT_animation 2_000166.png
Associate_TT_animation 2_000271.png
Associate_TT_animation 2_000329.png
Associate_TT_animation 2_000161.png
Associate_TT_animation 2_000276.png
Associate_TT_animation 2_000094.png
Associate_TT_animation 2_000352.png
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Analyzing duplicate handling and collisions**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1\_archive" -File | Select-Object -First 5 | Format-Table Name</summary>
```bash
Get-ChildItem "A:\1 Amazon_Active_Projects\251104_Turbotote\Renders\Associate_TT_animation 1\_archive" -File | Select-Object -First 5 | Format-Table Name
```
```
Name
----
Associate_TT_animation 1_000502.png
Associate_TT_animation 1_000163.png
Associate_TT_animation 1_000274.png
Associate_TT_animation 1_000208.png
Associate_TT_animation 1_000096.png
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Preparing to continue modifications**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"</summary>
```bash
Set-Location "A:\1 Amazon_Active_Projects\3 ProjectStructure"
```
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Reviewing and verifying task progress**</details></think>
---
<tool-use data-tool-type="generic" data-tool-name="read_lints">
<details>
<summary>Tool use: **read_lints** • Read lints for 5 files</summary>
Lint paths:
- `UpdateSequences.ps1`
- `zip_sequences.py`
- `ZipSeqArchv.bat`
- `UnzipSeqArchv.bat`
- `NewProject.bat`
Lint results
**No lint errors found**
</details>
</tool-use>
---
<think><details><summary>Thought Process</summary>
**Checking git status**</details></think>
---
<tool-use data-tool-type="bash" data-tool-name="run_terminal_cmd">
<details><summary>Tool use: **command** • Run command: git status -sb</summary>
```bash
git status -sb
```
```
## main...origin/main
M .specstory/history/2025-11-06_17-01Z-integrate-new-elements-and-update-sequences.md
M UpdateSequences.ps1
?? .specstory/history/2025-11-06_21-32Z-continue-integration-of-new-elements.md
```
</details>
</tool-use>
---
---
_**User (2025-11-06 21:32Z)**_
are you just manually renaming them?
---
_**Agent (model gpt-5-codex, mode Agent)**_
<think><details><summary>Thought Process</summary>
**Preparing response summaries**</details></think>
---
No manual steps. I ran the updated `UpdateSequences.ps1`, which now:
- Scans each sequence folder, resolving `_CURRENT` to its parent folder name.
- Renames every matching frame automatically under that parent name.
- Archives any conflicting duplicates into a local `_archive` subfolder so the rename can proceed.
For `Associate_TT_animation 1`, the folder now only has `Associate_TT_animation 1_*.png`; the `_CURRENT_*` files were either renamed or moved into `Associate_TT_animation 1\_archive`. Let me know if any folder still isnt following that pattern and Ill dig deeper.
---

View File

@@ -58,9 +58,32 @@ function Sync-SequenceFilenames {
$newPath = Join-Path $SequenceFolderPath $newName
try {
if (Test-Path -LiteralPath $newPath) {
$existing = Get-Item -LiteralPath $newPath -ErrorAction Stop
$sameSize = ($existing.Length -eq $f.Length)
$sameTime = ([math]::Abs(($existing.LastWriteTimeUtc - $f.LastWriteTimeUtc).TotalSeconds) -le 1)
if ($sameSize -and $sameTime) {
Remove-Item -LiteralPath $f.FullName -Force -ErrorAction Stop
$collisions++
if ($LogFile) { "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] RENAME DROP duplicate: '$($f.Name)' (matches '$newName')" | Add-Content -LiteralPath $LogFile }
continue
}
$archiveDir = Join-Path $SequenceFolderPath '_archive'
if (-not (Test-Path -LiteralPath $archiveDir)) {
New-Item -ItemType Directory -Path $archiveDir -Force | Out-Null
}
$archiveName = $existing.Name
$archivePath = Join-Path $archiveDir $archiveName
if (Test-Path -LiteralPath $archivePath) {
$stamp = Get-Date -Format 'yyyyMMdd_HHmmss'
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($archiveName)
$archivePath = Join-Path $archiveDir ("{0}_{1}{2}" -f $baseName, $stamp, $existing.Extension)
}
Move-Item -LiteralPath $existing.FullName -Destination $archivePath -Force -ErrorAction Stop
$collisions++
if ($LogFile) { "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] RENAME SKIP collision: '$($f.Name)' -> '$newName'" | Add-Content -LiteralPath $LogFile }
continue
if ($LogFile) { "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] RENAME ARCHIVE existing '$($existing.Name)' -> '$archivePath'" | Add-Content -LiteralPath $LogFile }
}
Rename-Item -LiteralPath $f.FullName -NewName $newName -ErrorAction Stop
$renamed++
@@ -136,6 +159,27 @@ function Rename-SequencePreviewMp4 {
}
}
function Resolve-SequenceName {
param(
[Parameter(Mandatory)] [System.IO.DirectoryInfo]$Directory
)
if ($Directory.Name -eq '_CURRENT' -and $Directory.Parent) {
return $Directory.Parent.Name
}
return $Directory.Name
}
function Add-SequenceFolder {
param(
[Parameter(Mandatory)] [System.IO.DirectoryInfo]$Directory,
[Parameter(Mandatory)] [hashtable]$Map
)
if ($Directory.Name -eq '_archive') { return }
$fullPath = $Directory.FullName
if ($Map.ContainsKey($fullPath)) { return }
$Map[$fullPath] = Resolve-SequenceName -Directory $Directory
}
try {
$root = (Get-Location).ProviderPath
$logFile = $null
@@ -145,24 +189,33 @@ try {
"[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] === UpdateSequences started in '$root' ===" | Out-File -LiteralPath $logFile -Encoding UTF8
}
$sequenceFolders = @()
$sequenceMap = @{}
$dailyDirs = Get-ChildItem -LiteralPath $root -Directory -Filter 'daily_*' -ErrorAction SilentlyContinue |
Where-Object { $_.Name -ne '_archive' }
foreach ($d in $dailyDirs) {
$seqDirs = @(Get-ChildItem -LiteralPath $d.FullName -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -ne '_archive' })
if ($seqDirs.Count -eq 0) {
$sequenceFolders += $d
Add-SequenceFolder -Directory $d -Map $sequenceMap
} else {
$sequenceFolders += $seqDirs
foreach ($s in $seqDirs) {
Add-SequenceFolder -Directory $s -Map $sequenceMap
}
}
}
$directSeqs = Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -ne '_archive' -and $_.Name -notlike 'daily_*' }
$sequenceFolders += $directSeqs
foreach ($seq in $directSeqs) {
Add-SequenceFolder -Directory $seq -Map $sequenceMap
}
$sequenceFolders = $sequenceFolders | Sort-Object -Property FullName -Unique
$sequenceFolders = $sequenceMap.GetEnumerator() | ForEach-Object {
[pscustomobject]@{
Path = $_.Key
Name = $_.Value
}
} | Sort-Object -Property Path
if (-not $sequenceFolders) {
Write-Host "No sequence folders found." -ForegroundColor Yellow
@@ -180,18 +233,18 @@ try {
foreach ($seq in $sequenceFolders) {
$totalSequences++
$renameResult = Sync-SequenceFilenames -SequenceFolderPath $seq.FullName -SequenceName $seq.Name -LogFile $logFile
$renameResult = Sync-SequenceFilenames -SequenceFolderPath $seq.Path -SequenceName $seq.Name -LogFile $logFile
if ($DebugMode -or $renameResult.Renamed -gt 0 -or $renameResult.Collisions -gt 0 -or $renameResult.Errors -gt 0) {
Write-Host "[RENAME]|$($seq.FullName)|$($seq.Name)|checked=$($renameResult.Checked)|renamed=$($renameResult.Renamed)|collisions=$($renameResult.Collisions)|errors=$($renameResult.Errors)" -ForegroundColor Cyan
Write-Host "[RENAME]|$($seq.Path)|$($seq.Name)|checked=$($renameResult.Checked)|renamed=$($renameResult.Renamed)|collisions=$($renameResult.Collisions)|errors=$($renameResult.Errors)" -ForegroundColor Cyan
}
$filesRenamedTotal += $renameResult.Renamed
$renameCollisions += $renameResult.Collisions
$renameErrors += $renameResult.Errors
if ($renameResult.FrameCount -gt 0 -and $renameResult.MinFrame -ne $null -and $renameResult.MaxFrame -ne $null) {
$mp4Result = Rename-SequencePreviewMp4 -SequenceFolderPath $seq.FullName -SequenceName $seq.Name -StartFrame $renameResult.MinFrame -EndFrame $renameResult.MaxFrame -LogFile $logFile
$mp4Result = Rename-SequencePreviewMp4 -SequenceFolderPath $seq.Path -SequenceName $seq.Name -StartFrame $renameResult.MinFrame -EndFrame $renameResult.MaxFrame -LogFile $logFile
if ($DebugMode -or $mp4Result.Renamed -gt 0 -or $mp4Result.Collisions -gt 0 -or $mp4Result.Errors -gt 0) {
Write-Host "[MP4]|$($seq.FullName)|$($seq.Name)|renamed=$($mp4Result.Renamed)|collisions=$($mp4Result.Collisions)|errors=$($mp4Result.Errors)" -ForegroundColor Cyan
Write-Host "[MP4]|$($seq.Path)|$($seq.Name)|renamed=$($mp4Result.Renamed)|collisions=$($mp4Result.Collisions)|errors=$($mp4Result.Errors)" -ForegroundColor Cyan
}
$mp4RenamedTotal += $mp4Result.Renamed
$mp4Collisions += $mp4Result.Collisions