I am trying to find some files, create a folder and move the files in there.
def test():
try:
logfile = "C:\\Users\\alkis\\Desktop\\testouter\\test"
result_dir = os.path.join(logfile, "testzip")
print result_dir
os.makedirs(result_dir)
os.chmod(result_dir, stat.S_IWRITE)
kpath = logfile + "\\*.jpg"
print kpath
files = glob.glob(kpath)
for file in files:
filename = os.path.splitext(file)[0]
print filename
os.chmod(filename, stat.S_IWRITE)
shutil.move(filename, result_dir)
except Exception, e:
#shutil.rmtree(result_dir)
print e.__doc__ + "\r\n"
print e.message
return
The error I am getting is: MS-Windows OS call failed
I check the permissions on my files and they are not read only.
You are listing each file, removing the extension, then trying to move that filename.
The extension is part of the filename, don't remove it. Windows Exlorer hides the extension only when displaying files.
You also don't need to call
os.chmod()
on the filename; just skip that step: