A few useful scripts for lora captions a LLM wrote for me (I don't know how to use a computer).
This one adds a certain string to the start of every txt file in the folder, save as a .bat, put in the folder and run:
@echo off
setlocal enabledelayedexpansion
set "text=This is a picture drawn by XXX. "
for %%i in (*.txt) do (
set "fileContent="
for /f "delims=" %%x in (%%i) do (
set "fileContent=!fileContent!%%x"
)
>%%i echo !text!!fileContent!
)
This one concatenates multiple paragraphs, to mitigate that problem >>102466495 Save as a .ps1 file, put in the folder, right click and select "Run with PowerShell":
# Get all txt files in the directory
$files = Get-ChildItem -Filter *.txt
foreach ($file in $files) {
# Read each line from file and concatenate them
$content = (Get-Content $file.FullName) | ForEach-Object { $_ -replace "`r", "" }
# Replace multiple spaces with a single space, then trim leading/trailing spaces
$content = $content -join ' ' -replace '\s+', ' ' -replace '^\s|\s$'
# Write the modified content back to file
Set-Content -Path $file.FullName -Value $content
}