wiki:FileServer/listing/rename.py

Version 1 (modified by pangchongyang, 15 years ago) (diff)

--


#!/usr/bin/env python

# for more detail, see http://docs.python.org/

import os

files = []
for i in os.listdir("."):
    if i.endswith(".png"):
        files.append(i)

idx = 0
for j in files:
    oldFilename = j
    newFilename = "%d.png" % idx
    os.rename(oldFilename, newFilename)
    idx += 1