1.txt ⇒ 2.txt
2.txt ⇒ 3.txt
3.txt ⇒ 4.txt
もっと良いやり方あったら教えてくださいm(_ _)m
import os
path = "./dirname"
folderfile = os.listdir(path)
file = [f for f in folderfile if os.path.isfile(os.path.join(path, f))]
newlist = sorted(file, reverse=True)
for f in newlist:
basename_without_ext = int(os.path.splitext(os.path.basename(f))[0])
before_name = os.path.join(path,f)
after_name = os.path.join(path, str(basename_without_ext + 1) + os.path.splitext(os.path.basename(f))[1])
os.rename(before_name,after_name)