-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfile_renamer.py
executable file
·55 lines (45 loc) · 1.33 KB
/
file_renamer.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
__author__ = "Jugal Kishore & Akash Shiva"
__version__ = "1.0"
import os
def rename_function():
current_folder = os.curdir
filepaths = os.listdir(current_folder)
num = 0
for name in filepaths:
os.rename(name, name.replace(" ", "_"))
renamed = name.replace(" ", "_")
if name != renamed:
num += 1
print(name + " ---> " + renamed)
if num == 0:
print("Nothing changed")
def rename_to_lower():
current_dir = os.curdir
file_name = os.listdir(current_dir)
num = 0
for name in file_name:
os.rename(name, name.lower())
renamed = name.lower()
if name != renamed:
num += 1
print(name + " ---> " + renamed)
if num == 0:
print("No file changed")
print("///File Renamer///\n")
print("1. Space Remover")
print("2. File Name Upper to Lower")
print("3. Space Remover + File Name Upper to Lower")
print("Anything to exit")
choice = input()
if choice == "1":
rename_function()
elif choice == "2":
rename_to_lower()
elif choice == "3":
rename_function()
rename_to_lower()
else:
print("Exiting!")
print("\nCreated by Jugal Kishore & Akash Shiva -- 2020")
# Run it online at https://python.jugalkishore.repl.run/