2022年9月30日 星期五

Rename Multiple Files Using Python

Using python to rename multiple files


 import os


rootdir = r'target'

str = "08"

for filename in os.listdir(rootdir):

    if str in filename:

        filepath = os.path.join(rootdir, filename)

        newfilepath = os.path.join(rootdir, filename.replace(str, "09"))

        os.rename(filepath, newfilepath)

沒有留言:

張貼留言

Python program to display calendar

# Python program to display calendar of given month of the year # importing calendar module for calendar operations import calendar # set t...