I'm trying to rename all the pictures in a directory. I need to add a couple of pre-pending zero's to the filename. I'm new to Python and I have written the following script.
import os
path = "c:\\tmp"
dirList = os.listdir(path)
for fname in dirList:
fileName = os.path.splitext(fname)[0]
fileName = "00" + fname
os.rename(fname, fileName)
#print(fileName)
The commented print line was just to verify I was on the right track. When I run this I get the following error and I am at a loss how to resolve it.
Traceback (most recent call last): File "C:\Python32\Code\add_zeros_to_std_imgs.py", line 15, in os.rename(fname, fileName) WindowsError: [Error 2] The system cannot find the file specified
Any help is greatly appreciated. Thnx.