I have a list of files. Each filename contains a digit which I want to remove. I then want to rename the file with the new filename (without digits). Getting an error below:
Code below :
import os, re
mypath = "/Users/tikka/Downloads/prank/prank"
for f in os.listdir(mypath):
print f
frenamed = re.sub('\d','',f)
print frenamed
os.rename(f,frenamed)
print f
Error Message
Traceback (most recent call last):
File "C:/Python27/ty3.py", line 7, in <module>
os.rename(f,frenamed)
WindowsError: [Error 2] The system cannot find the file specified
This question is different to Rename Files in Python as my .py is not in the same directory as the files that I wish to rename