[Solved] Renaming files that have specific format like text.* [closed]


You can use glob for get all files with pattern coord.* in your path and rename them with os.rename.

import os
import glob

path="Files/"

for file in glob.glob(path+'coord.*'):
    f,s = file.split('.',1)
    file_new = f+'N.'+s
    os.rename(file, file_new)

First filenames:

coord.1.txt
coord.1.png

After renaming:

coordN.1.txt
coordN.1.png

0

solved Renaming files that have specific format like text.* [closed]