Given multiple files in a directory having different names, the task is to rename all those files in sorted order.
We can use OS module in order to do this operation. The OS module in python provides functions for interacting with the operating system and provides a portable way of using operating system dependent functionality. We can go to the current working directory using
os.getcwd() method and rename the files with
Below is the Python implementation :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.