This is the place for queries that don't fit in any of the other categories.
So iam trying to rename about 100 hundred pictures in folder change_name
- Code: Select all
x = 0
array = os.listdir("c:/Users/Acer/Desktop/change_name/") # makes a list of files in change_name folder
for file in array:
os.rename(file,file +str(x)) #here is problem...keep showing me errorFileNotFoundError: [WinError 2] : 'out0000.png0'....first argument os.rename should be real name of file,second - new name....i understand it in this way but maybe iam wrong
Last edited by kostik
on Fri Jul 19, 2013 1:35 pm, edited 1 time in total.
- Posts: 13
- Joined: Tue Apr 16, 2013 10:26 am
You didn't include a traceback of the error you are getting.
Here are some things to think about:
What does os.listdir return?
When loop array what is file?
When calling os.rename what does it expect the src & dst to be?
what are you actually calling os.rename with when you are doing os.rename(file,file +str(x))?
- Posts: 1284
- Joined: Fri Feb 08, 2013 1:35 am
- Location: UK
Return to General Coding Help
Who is online
Users browsing this forum: No registered users and 3 guests