我正在尝试找到一些文件,创建一个文件夹,并将这些文件移到那里。在
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
我得到的错误是:MS-Windows OS call failed
我检查我的文件的权限,它们不是只读的。在
列出每个文件,删除扩展名,然后尝试移动该文件名。在
扩展名是文件名的一部分,不要删除它。Windows Exlorer只在显示文件时隐藏扩展名。在
您也不需要对文件名调用
os.chmod()
;只需跳过该步骤:相关问题 更多 >
编程相关推荐