I have a folder of .srt files that are not synced correctly with the RAWs of a TV series, as those RAWs don't include the opening. If it was a single file what I'd do would be using the Aegisub's Times Shift option to to increase/decrease the subtitle's starting and ending position with a given length (in this case I need to "delay" every subtitle by 2 minutes and 56 seconds). However I need to do this for 49 files but I don't know a way to bulk edit all the files.
+ Reply to Thread
Results 1 to 4 of 4
-
-
Open subtitle edit/tools/batch convert/offset time codes then drag the folder into batch convert.
I think,therefore i am a hamster. -
i do this with python script and subtitleedit...
This edits and remerges english srt subs for all mkv files in a folder.
import os
import subprocess, shlex
import re
#LOCATION OF APPS/binaries
subtitleedit = "C:\Program Files\Subtitle Edit\SubtitleEdit.exe"
directory= "C:/Program Files/MKVToolNix/mkvmerge.exe"
#get directory, files
cwd = os.getcwd()
files = os.listdir()
for file in files:
print(f"converting {file}")
if "E01" in file or "E02" in file or "E03" in file: #I had situation where some episodes needed different offsets, and i had manually specified it, this isnt really critical.
os.system(f'"{subtitleedit}" /convert {cwd}/{file} srt /offset:-00:00:10:00') #-00:00:10:00 here sets the subtitles 10 seconds earlier.
else:
os.system(f'"{subtitleedit}" /convert {cwd}/{file} srt /offset:-00:00:10:00')
print("conversion complete\n")
#remerge fsubs into file
files = os.listdir()
cwd = os.getcwd()
list = []
for file in files:
if file.endswith(".mkv"):
list.append(file[:-3])
#print(str(list))
#print(cwd)
for file in list:
title = re.search("(.+S\d+E\d+.+)1080", file)
try:
title = title.group(1)
except:
title = re.search("(.+\d{4})\.1080", file)
title = title.group(1)
title = title.replace("."," ")
print(title)
print(f"remerging subs for {file}")
mycmd = f'"{directory}" --ui-language en --priority lower --output "{cwd}/o{file}mkv" --no-subtitles --language 0:en --display-dimensions 0:1920x1080 --language 1:en "(" "{cwd}/{file}mkv" ")" --language 0:en --track-name 0:English --default-track-flag 0:no --track-enabled-flag 0:no "(" "{cwd}/{file}eng.srt" ")" --title "{title}" --track-order 0:0,0:1,1:0'
subprocess.run(shlex.split(mycmd))
print(f"merged subs for {file}\n")
if os.path.exists(f"{cwd}/o{file}mkv"):
print("removing old files")
os.remove(f"{cwd}/{file}mkv")
os.remove(f"{cwd}/{file}eng.srt")
print("renaming new file")
os.rename(f"{cwd}/o{file}mkv", f"{cwd}/{file}mkv")
Similar Threads
-
Any way to batch join .srt subtitle files in multiple parts?
By seanmcnally in forum SubtitleReplies: 4Last Post: 14th Apr 2024, 13:21 -
Help with Aegisub - copy-paste length and timing of subtitles into new srt?
By LaytonsApprentice2 in forum SubtitleReplies: 10Last Post: 5th Feb 2021, 15:24 -
Change Encoding to UTF-8 on Multiple Srt Files.
By smounche in forum SubtitleReplies: 11Last Post: 16th Mar 2020, 02:56 -
Convert Frame Rate Across Multiple SRT files
By twathle in forum SubtitleReplies: 0Last Post: 5th Jul 2018, 02:50 -
How to batch translate multiple SRT files
By demowolf in forum SubtitleReplies: 2Last Post: 22nd Jun 2018, 00:02