Created
February 8, 2015 13:48
-
-
Save OrganicIrradiation/9343ca746807a71693c9 to your computer and use it in GitHub Desktop.
hb_batchconvertvideos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import subprocess | |
import sys | |
fileList = [] | |
rootdir = raw_input("Root Dir: ") | |
for root, subFolders, files in os.walk(rootdir): | |
for file in files: | |
theFile = os.path.join(root,file) | |
fileName, fileExtension = os.path.splitext(theFile) | |
if fileExtension.lower() in ('.avi', '.divx', '.flv', '.m4v', '.mkv', '.mov', '.mpg', '.mpeg', '.wmv'): | |
print 'Adding',theFile | |
fileList.append(theFile) | |
runstr = '"C:Program FilesHandbrakeHandBrakeCLI.exe" -i "{0}" -o "{1}" --preset="Normal" --two-pass --turbo' | |
print '=======--------=======' | |
while fileList: | |
inFile = fileList.pop() | |
fileName, fileExtension = os.path.splitext(inFile) | |
outFile = fileName+'.mp4' | |
print 'Processing',inFile | |
returncode = subprocess.call(runstr.format(inFile,outFile)) | |
time.sleep(5) | |
print 'Removing',inFile | |
os.remove(inFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some OS might need to edit line 26 to be:
returncode = subprocess.call(runstr.format(inFile,outFile), shell=True)
and in Python 3 raw_input () is just input()