python 批量移除密码
import msoffcrypto
import pathlib
def unlock(filename, passwd, output_folder):
temp = open(filename, 'rb')
excel = msoffcrypto.OfficeFile(temp)
excel.load_key(passwd)
out_path = pathlib.Path(output_folder)
if not out_path.exists():
out_path.mkdir()
with open(str(out_path/filename.name), 'wb') as f:
excel.decrypt(f)
temp.close()
def convert_path(win_path):
tmp_path = win_path.replace(":", "")
tmp_path = tmp_path.replace("\\", "/")
tmp_path = tmp_path.lower()
tmp_path = "/mnt/" + tmp_path
return (tmp_path)
if __name__ == '__main__':
key="2022"
url = pathlib.Path(convert_path(r"C:\Users\xuefe\Downloads\Video"))
files = list(url.glob('*.*'))
for f in files:
unlock(f, key, r'/mnt/c/users/xuefe/downloads/')
评论
发表评论