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, 14:21
- 
  Help with Aegisub - copy-paste length and timing of subtitles into new srt?By LaytonsApprentice2 in forum SubtitleReplies: 10Last Post: 5th Feb 2021, 16:24
- 
  Change Encoding to UTF-8 on Multiple Srt Files.By smounche in forum SubtitleReplies: 11Last Post: 16th Mar 2020, 03:56
- 
  Convert Frame Rate Across Multiple SRT filesBy twathle in forum SubtitleReplies: 0Last Post: 5th Jul 2018, 03:50
- 
  How to batch translate multiple SRT filesBy demowolf in forum SubtitleReplies: 2Last Post: 22nd Jun 2018, 01:02


 
		
		 View Profile
				View Profile
			 View Forum Posts
				View Forum Posts
			 Private Message
				Private Message
			 
 
			
			
 Quote
 Quote 
			