I am trying to rename multiple files to a directory using this Python script:
import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1
When I run this script, I get the following error:
Traceback (most recent call last): File "rename.py", line 7, in <module> os.rename(file, str(i)+'.jpg') OSError: [Errno 2] No such file or directory
Why? How can I solve this problem?
Thank.
python directory rename
Simplicity May 26 '16 at 17:33 2016-05-26 17:33
source share