I am trying to rename those images so image_0596(2) changed to iamge_0596 After that I want to increment the file number so previous image_0596 => image_0597 and previous image_0598 => image_0599 ...... However, the block of my code doesn't replace anything.
from itertools import count
import os
def main():
path =''
lst = os.listdir(path)
os.chdir(path)
for filename in os.listdir(path):
if filename.endswith('.jpg'):
filename = ("image_%04i.jpg" % i for i in count(1))

mainfunction needs to be indentedfilenamecause any change to the actual name of the file on the disk? Did you try to research about how to rename files, for example by using a search engine?