I think that just because you have the wrong syntax in your os.path.join call, the elements you connect should be represented as two different arguments, separated by commas. This works fine for me:
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> path = os.getcwd() >>> filenames = os.listdir(path) >>> for filename in filenames: ... os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(' ', '-'))) ... >>>
source share