Posts

Showing posts from April, 2023

Python code to unprotect the excel sheet with a valid password

import msoffcrypto import pathlib # pip install msoffcrypto-tool' url = pathlib.Path(r'D:\Source') excel_files = list(url.glob('*.xlsx')) 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() for i in excel_files:     unlock(i, 'Password', r'D:\Destination') ------------------------------ # Replace "C:\Your\Directory\Path" with the actual path to the directory you want to search in. $directoryPath = "D:\Testing" # Replace "2023-06-30" with the date you want to check in "YYYY-MM-DD" format. $targetDate = "2023-06-30" # Get all the *.txt files in the specified directory that match the ...