-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
使用原脚本时,总是提示目标文件夹中的某文件不存在,应该是source设置为了toFullName导致的。
可以改写为读写文件的方式,测试ok。
附参考链接:http://blog.csdn.net/jy692405180/article/details/52409369
修改后的脚本如下:
for root, dirs, files in os.walk(fromFilePath):
for name in files:
fileName, fileSuffix = os.path.splitext(name)
if fileSuffix == '.png' or fileSuffix == '.jpg':
toFullPath = toFilePath + root[len(fromFilePath):]
toFullName = toFullPath + '/' + name
fromFullPath = fromFilePath + root[len(fromFilePath):]
fromFullName = fromFullPath + '/' + name
if os.path.isdir(toFullPath):
pass
else:
os.mkdir(toFullPath)
source = tinify.from_file(fromFullName)
source.to_file(toFullName)
rensss
Metadata
Metadata
Assignees
Labels
No labels