I wanted to know what is the easiest way to rename multiple files using re module in python if at all it is possible.
In my directory their are 25 files all with the file names in the format ‘ A unique name followed by 20 same characters.mkv ‘
What I wanted was to delete all the 20 characters.
How can I do this using Python if at all it is possible 🙂
To get the new name:
Or without regex:
To rename the file use
os.rename(old, new): http://docs.python.org/library/os.html#os.renameTo get a list of the files to rename use
glob.glob('*.mkv'): http://docs.python.org/library/glob.html#glob.globPutting that all together we get: