Skip to content

Instantly share code, notes, and snippets.

@nhtera
Last active April 9, 2017 16:47
Show Gist options
  • Save nhtera/a1e0fae62f1c8524b4a97c6a91d922a2 to your computer and use it in GitHub Desktop.
Save nhtera/a1e0fae62f1c8524b4a97c6a91d922a2 to your computer and use it in GitHub Desktop.
MacOSX - Scan dir auto-generating subtitles for any video file (*.mp4)
#!/usr/local/opt/python/bin/python2.7
# Install autosub first by follow the instruction: https://github.com/agermanidis/autosub
import os
import sys
walk_dir = os.getcwd()
count = 0
for root, subdirs, files in os.walk(walk_dir):
for file in files:
if (file.split(".")[-1] == 'mp4'):
filePath = os.path.join(root, file)
subFilePath = os.path.join(root, os.path.splitext(file)[0] + ".srt")
if os.path.isfile(subFilePath):
continue
os.system("autosub " + "\"" + filePath + "\"")
count = count + 1
print "\"" + filePath + "\""
print "Done the total number of file was be processed: ", count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment