Skip to content

Commit

Permalink
old script used to rename movies
Browse files Browse the repository at this point in the history
  • Loading branch information
rboman committed Dec 2, 2023
1 parent 8fffe98 commit 1f8a65d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions bin/avi_name_cleaner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# usage: avi_name_cleaner.py [rename]
#

import os, os.path, sys


def clean(rename=False):
"""
Clean filenames in current directory
"""
# for file in os.listdir('.'):
for root, dirs, files in os.walk('.'):
for file in files:
fullfile = os.path.join(root, file)
if os.path.isfile(fullfile):
base, ext = os.path.splitext(file)
ext = ext.lower()
if ext in ['.avi', '.sub', '.idx', '.srt', '.asf', '.mpg', '.wmv', '.mp4', '.mkv']:
base = base.replace('.', ' ')
base = base.replace('_', ' ')
base = base.replace('cd1', 'CD1')
base = base.replace('cd2', 'CD2')
# base = base.title()
newfile = base + ext
if file != newfile:
if rename:
print("renaming",
os.rename(fullfile, os.path.join(root, newfile)))
print("'%s' => '%s'" % (file, newfile))


if __name__ == "__main__":
rename = False
for arg in sys.argv[1:]:
if arg == "rename":
rename = True
clean(rename)

print("\n[ENTER]")
input()

0 comments on commit 1f8a65d

Please sign in to comment.