Skip to content

Commit 247900e

Browse files
authored
Create FileSorter.py
1 parent d6c35aa commit 247900e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

FileSorter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from rich import print
2+
import os
3+
4+
FileArray = []
5+
6+
for path in os.listdir(fr"{os.getcwd()}"):
7+
if os.path.isfile(os.path.join(fr"{os.getcwd()}", path)):
8+
FileArray.append(path)
9+
try:
10+
for i in range(0, len(FileArray)):
11+
if "." not in FileArray[i] or FileArray[i] == str(__file__):
12+
continue
13+
14+
new_file_name = f"File-{i+1}.{str(FileArray[i]).split('.')[1]}"
15+
os.rename(str(FileArray[i]), new_file_name)
16+
print(f"Renamed {FileArray[i]} -> {new_file_name}")
17+
18+
except Exception as exception:
19+
print(f"[red]{exception}[/red]")

0 commit comments

Comments
 (0)