STTinyPNG-Python icon indicating copy to clipboard operation
STTinyPNG-Python copied to clipboard

脚本无法使用,可以参考以下方式修改

Open gaojingwen945 opened this issue 9 years ago • 3 comments

使用原脚本时,总是提示目标文件夹中的某文件不存在,应该是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)

gaojingwen945 avatar Dec 09 '16 07:12 gaojingwen945

好的,谢谢

saitjr avatar Dec 09 '16 08:12 saitjr

修改之后报错 IndentationError: unindent does not match any outer indentation level

Aeiric avatar Jan 13 '18 12:01 Aeiric

额 无视上面那个问题 还是filenotfound

Aeiric avatar Jan 13 '18 12:01 Aeiric