i need to rename a multiple files in a folder with numbers increament in python -


i need rename multiple files folder numbers increament in python.i.e. first file in folder gets renamed 1 , second file name 2.like that..how solve this

you should first iterate through files in directory, , rename files.

it might this:

import os  # let's want rename files in current directory index = 1 filename in os.listdir(os.getcwd()):     os.rename(filename, '_'.join([str(index),filename]))     index += 1 

this can approach , should adapt needs.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -