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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -