i rewrote the script for powershell, this should work on windows no problem.
(save as .ps1)
# Prompt for frame rate
$frate = Read-Host "frame rate"
if (-not $frate) { $frate = 60 }
Write-Host "..."
# Remove existing Kden_Titles directory if it exists
if (Test-Path -Path "./Kden_Titles/") { Remove-Item -Path "./Kden_Titles/" -Recurse -Force }
New-Item -ItemType Directory -Path "Kden_Titles"
# Read frames and subtitles from SRT files
$frm = Get-Content -Path '*.srt' | Select-Object -Skip 1 | ForEach-Object -Begin {$i=0} -Process {if ($i++ % 4 -eq 0) {$_}}
$sub = Get-Content -Path '*.srt' | Select-Object -Skip 2 | ForEach-Object -Begin {$i=0} -Process {if ($i++ % 4 -eq 0) {$_}}
# output File name width / counter
$w = [math]::Ceiling($sub.Count * 2)
$w = "$w".length
$n = 1
# Template file placeholders
[regex] $p_1='30'
[regex] $p_2='%s'
for ($i = 0; $i -lt $frm.Count; $i++) {
# Timing
$b = [datetime]::ParseExact($frm[$i].Substring(0, 12), "hh:mm:ss,fff", $null).ToString("ss.fff")
$e = [datetime]::ParseExact($frm[$i].Substring(17, 12), "hh:mm:ss,fff", $null).ToString("ss.fff")
$ee = if ($i -gt 0) { [datetime]::ParseExact($frm[$i - 1].Substring(17, 12), "hh:mm:ss,fff", $null).ToString("ss.fff") } else { 0 }
# Add 60s if necessary
if ($i -eq 0) { $ee = 0 }
if ($b -lt $ee -and $i -ne 0) { $b = [math]::Round([double]$b + 60, 3) }
if ($e -lt $b) { $e = [math]::Round([double]$e + 60, 3) }
# Clip length / padding
$blank = [math]::Round([decimal]$b * $frate + 0.1) - [math]::Round([decimal]$ee * $frate + 0.1)
$duration = [math]::Round([decimal]$e * $frate + 0.1) - [math]::Round([decimal]$b * $frate + 0.1)
# Replace placeholders
if ($blank -gt 0) {
Get-Content -Path ./*.kdenlivetitle* |
ForEach-Object { $p_1.replace("$_", "$blank", 1) } |
ForEach-Object { $p_2.replace("$_", '',1) } |
Set-Content -Path "./Kden_Titles/$($n.ToString("D$w"))_.kdenlivetitle"
$n++
}
Get-Content -Path ./*.kdenlivetitle* |
ForEach-Object { $p_1.replace("$_", "$duration", 1) } |
ForEach-Object { $p_2.replace("$_", $sub[$i],1) } |
Set-Content -Path "./Kden_Titles/$($n.ToString("D$w")).kdenlivetitle"
$n++
}
Start-Sleep -Seconds 1
Write-Host "`nTitles in $PWD\Kden_Titles`n"
# Set date modified for blank clips
(Get-ChildItem -Path ./Kden_Titles/*_*) | % {$_.LastWriteTime = (Get-Date)}
( Btw is there a limit on post edits ? can’t seem to edit my original post )