File size: 469 Bytes
c2e82c1 36225f1 c2e82c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))
for file in os.listdir():
if file.endswith(".txt"):
if os.path.exists(f'txt logs/{file}'):
n = 1
file2 = file[:-4] + f"_{n}.txt"
while os.path.exists(f'txt logs/{file2}'):
n += 1
file2 = file[:-4] + f"_{n}.txt"
os.rename(file, f'txt logs/{file2}')
continue
os.rename(file, f"txt logs/{file}") |