Last active
March 16, 2018 13:20
-
-
Save astrograzl/b052ef01f6636764fcf36ebb5842f2af to your computer and use it in GitHub Desktop.
Rename subtitle files with respekt to movie filenames.
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
#!python | |
# coding: utf-8 | |
"""Rename subtitle files with respekt to movie filenames. | |
$ python reset.py "Movies*.mkv" "Subtitles*.srt" | |
The quotation marks are important to prohibit shell expanse of the filenames | |
mask. It is expected, that the files will be sorted in the same right order. | |
""" | |
import os | |
import sys | |
import glob | |
assert len(sys.argv) == 3 | |
MOVIES = sorted(glob.glob(sys.argv[1])) | |
SUBTIT = sorted(glob.glob(sys.argv[2])) | |
assert len(MOVIES) == len(SUBTIT) | |
for mov, sub in zip(MOVIES, SUBTIT): | |
new = mov[:-3] + sub[-3:] | |
os.rename(sub, new) | |
print("{}\t==>\t{}".format(sub, new)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment