-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixChar.py
More file actions
32 lines (25 loc) · 793 Bytes
/
fixChar.py
File metadata and controls
32 lines (25 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os, sys
path = sys.argv[1]
try:
charOp = sys.argv[2]
except:
charOp = None
outChar = '_'
chars = ['/', '\\', '|', '#', '/', '?', '¿', '⧸', charOp]
files = os.listdir(path)
for file_name in files:
save_file = False
old_name = file_name
for char in chars:
if char is not None and char in file_name:
if not save_file:
save_file = True
new_name = file_name.replace (char, outChar)
else:
new_name = new_name.replace (char, outChar)
if save_file:
if charOp != None:
new_name = new_name.replace (charOp, outChar)
os.rename (path+old_name, path+new_name)
print (new_name)
print ("yt-downloader and fixChar have finished")