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))?
Due to the reasons discussed here
we will be moving to python-forum.io/
on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.