Upload fixPaths.ps1
Browse filesUpdates ComfyUI workflows searching and replacing for model files where the path is no w different, or a new model name is out. It runs recursively on all the files in the folder you specify, and before updating them, it will delete them to the recycle bin in case you need to recover them. Best to make a backup first.
- fixPaths.ps1 +114 -0
fixPaths.ps1
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Recursively search and replace through *.json workflows for model names or paths that you want to change
|
| 2 |
+
# Before updating a file, it will delete it to your recycle bin in case you want to recover it.
|
| 3 |
+
|
| 4 |
+
# Root directory (modify this and the string replacements for the models)
|
| 5 |
+
|
| 6 |
+
$rootPath = "C:\Data\ComfyUser\default\workflows\LTX\"
|
| 7 |
+
|
| 8 |
+
$replacements = [ordered]@{
|
| 9 |
+
|
| 10 |
+
# 1.1 distilled LTX-2.3
|
| 11 |
+
"ltx-2.3-22b-distilled-lora-384.safetensors" = "ltx-2.3-22b-distilled-lora-384-1.1.safetensors"
|
| 12 |
+
"ltx-2.3-22b-distilled.safetensors" = "ltx-2.3-22b-distilled-1.1.safetensors"
|
| 13 |
+
|
| 14 |
+
# Transformer (dev)
|
| 15 |
+
"LTXVideo\v2\ltx-2.3-22b-dev_transformer_only_fp8_scaled.safetensors" = "ltx-2-3-22b-dev_transformer_only_fp8_input_scaled.safetensors"
|
| 16 |
+
"LTXVideo\\v2\\ltx-2.3-22b-dev_transformer_only_fp8_scaled.safetensors" = "ltx-2-3-22b-dev_transformer_only_fp8_input_scaled.safetensors"
|
| 17 |
+
|
| 18 |
+
# LoRA (path cleanup)
|
| 19 |
+
"LTX\LTX-2\ltx-2.3-22b-distilled-lora-384.safetensors" = "ltx-2.3-22b-distilled-lora-384.safetensors"
|
| 20 |
+
"LTX\\LTX-2\\ltx-2.3-22b-distilled-lora-384.safetensors" = "ltx-2.3-22b-distilled-lora-384.safetensors"
|
| 21 |
+
|
| 22 |
+
# Spatial upscaler (FIXED)
|
| 23 |
+
"ltx-2.3-spatial-upscaler-x2-1.0.safetensors" = "ltx-2.3-spatial-upscaler-x2-1.1.safetensors"
|
| 24 |
+
|
| 25 |
+
# Distilled transformer
|
| 26 |
+
"LTXVideo\v2\ltx-2.3-22b-distilled_transformer_only_fp8_scaled.safetensors" = "ltx-2.3-22b-distilled_transformer_only_fp8_input_scaled_v3.safetensors"
|
| 27 |
+
"LTXVideo\\v2\\ltx-2.3-22b-distilled_transformer_only_fp8_scaled.safetensors" = "ltx-2.3-22b-distilled_transformer_only_fp8_input_scaled_v3.safetensors"
|
| 28 |
+
|
| 29 |
+
# VAE cleanup - on my system it wouldn't pick it up in vae_approx so I personally have these uncommented
|
| 30 |
+
"vae_approx\taeltx2_3.safetensors" = "taeltx2_3.safetensors"
|
| 31 |
+
"vae_approx\\taeltx2_3.safetensors" = "taeltx2_3.safetensors"
|
| 32 |
+
|
| 33 |
+
# Gemma
|
| 34 |
+
"gemma_3_12B_it_fpmixed.safetensors" = "gemma_3_12B_it_fp8_scaled.safetensors"
|
| 35 |
+
|
| 36 |
+
# Additional VAE replacements
|
| 37 |
+
"LTX23_audio_vae_bf16_KJ.safetensors" = "LTX23_audio_vae_bf16.safetensors"
|
| 38 |
+
"LTX23_video_vae_bf16_KJ.safetensors" = "LTX23_video_vae_bf16.safetensors"
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
Add-Type -AssemblyName Microsoft.VisualBasic
|
| 42 |
+
|
| 43 |
+
function Get-LiteralMatchCount {
|
| 44 |
+
param (
|
| 45 |
+
[string]$Text,
|
| 46 |
+
[string]$Search
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
if ([string]::IsNullOrEmpty($Search)) {
|
| 50 |
+
return 0
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
$count = 0
|
| 54 |
+
$startIndex = 0
|
| 55 |
+
|
| 56 |
+
while ($true) {
|
| 57 |
+
$index = $Text.IndexOf($Search, $startIndex, [System.StringComparison]::Ordinal)
|
| 58 |
+
if ($index -lt 0) {
|
| 59 |
+
break
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
$count += 1
|
| 63 |
+
$startIndex = $index + $Search.Length
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
return $count
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
$files = Get-ChildItem -Path $rootPath -Recurse -Filter *.json -File
|
| 70 |
+
|
| 71 |
+
foreach ($file in $files) {
|
| 72 |
+
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
|
| 73 |
+
$originalContent = $content
|
| 74 |
+
$changed = $false
|
| 75 |
+
|
| 76 |
+
foreach ($oldValue in $replacements.Keys) {
|
| 77 |
+
$newValue = $replacements[$oldValue]
|
| 78 |
+
|
| 79 |
+
$count = Get-LiteralMatchCount -Text $content -Search $oldValue
|
| 80 |
+
|
| 81 |
+
if ($count -gt 0) {
|
| 82 |
+
$content = $content.Replace($oldValue, $newValue)
|
| 83 |
+
|
| 84 |
+
Write-Host "[$($file.Name)] Replaced $count occurrence(s):"
|
| 85 |
+
Write-Host " OLD: $oldValue"
|
| 86 |
+
Write-Host " NEW: $newValue"
|
| 87 |
+
$changed = $true
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
if ($changed -and $content -ne $originalContent) {
|
| 92 |
+
try {
|
| 93 |
+
# Send original file to Recycle Bin
|
| 94 |
+
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(
|
| 95 |
+
$file.FullName,
|
| 96 |
+
[Microsoft.VisualBasic.FileIO.UIOption]::OnlyErrorDialogs,
|
| 97 |
+
[Microsoft.VisualBasic.FileIO.RecycleOption]::SendToRecycleBin
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
# Write updated content back to original path
|
| 101 |
+
Set-Content -Path $file.FullName -Value $content -Encoding UTF8
|
| 102 |
+
|
| 103 |
+
Write-Host "Updated: $($file.FullName)"
|
| 104 |
+
Write-Host ""
|
| 105 |
+
}
|
| 106 |
+
catch {
|
| 107 |
+
Write-Host "ERROR updating: $($file.FullName)"
|
| 108 |
+
Write-Host " $($_.Exception.Message)"
|
| 109 |
+
Write-Host ""
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
Write-Host "Done."
|