file2
Browse files- Client/clear_texts.py +8 -0
Client/clear_texts.py
CHANGED
|
@@ -4,4 +4,12 @@ os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
|
| 4 |
|
| 5 |
for file in os.listdir():
|
| 6 |
if file.endswith(".txt"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
os.rename(file, f"txt logs/{file}")
|
|
|
|
| 4 |
|
| 5 |
for file in os.listdir():
|
| 6 |
if file.endswith(".txt"):
|
| 7 |
+
if os.path.exists(f'txt logs/{file}'):
|
| 8 |
+
n = 1
|
| 9 |
+
file2 = file[:-4] + f"_{n}.txt"
|
| 10 |
+
while os.path.exists(f'txt logs/{file2}'):
|
| 11 |
+
n += 1
|
| 12 |
+
file2 = file[:-4] + f"_{n}.txt"
|
| 13 |
+
os.rename(file, f'txt logs/{file2}')
|
| 14 |
+
continue
|
| 15 |
os.rename(file, f"txt logs/{file}")
|