How to rename thousand of files

In the video you will see how I rename a lot of files at once, with just a couple of lines of python.

An example could be this, but in the video I am more specific, showing how to change the names of some images and why do I needed to do it.

from glob import glob
import os

imgs = glob("*.png")
for i in img:
    os.rename(i, "newname" + str(img.index(i) + 1) + ".png"

You can use this feature in many occasions. This will make you save a lot of time.


Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.