Created
February 27, 2024 11:31
-
-
Save SanSan-/e8f6da6ebaf55df4ebd5dd1fdcfed82f to your computer and use it in GitHub Desktop.
Copy-Paste batch of captions for photos to wd14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$SelectPath = $args[0] # "D:\Photos\+stable-diffusion\lora\TriggerWord\IMG\N_TriggerWord\" | |
$TriggerWord = $args[1] # "TriggerWord" | |
if ($args[2] -ne $null) { | |
$FromExt = $args[2] | |
} else { | |
$FromExt = ".txt" | |
} | |
if ($args[3] -ne $null) { | |
$ToExt = $args[3] | |
} else { | |
$ToExt = ".wd14" | |
} | |
$files = Get-ChildItem -Path $SelectPath -Recurse | Where-Object {$_.Extension -eq $FromExt} | |
Write-Output $files | |
foreach ($file in $files) | |
{ | |
$dirName = $file.DirectoryName | |
$fileName = $file.Basename | |
$from = "$dirName\$fileName$FromExt" | |
$to = "$dirName\$fileName$ToExt" | |
Add-Content $from "`n===`nphoto of $TriggerWord, " | |
Write-Output "Add $TriggerWord to $from complete!" | |
Copy-Item -Path $from -Destination $to | |
Write-Output "Copy to $to complete!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment