filenames - Python - WindowsError: [Error 2] The system cannot find the file specified -


i have folder full of pdf files. i'm trying remove spaces files name , replace them underscores. here's have far:

import os, sys  folder = path folder filelist = os.listdir(folder)  files in filelist:     if ' ' in files:         newname = files.replace(" ", "_")         os.rename(files, newname) 

when run script following error:

windowserror: [error 2] system cannot find file specified 

i'm guessing there pretty simple fix, i've on , cannot find solution life of me.

thanks help!

...

os.rename(os.path.join(folder, files), os.path.join(folder, newname)) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -