Regarding my problem, I require assistance "WinError 32: [PermissionError] The file is being used by another process, thus the process cannot access it: ".
Therefore, the script below deletes a folder that contains an excel file. When the excel file is opened, the shutil.rmtree(dirpath) command is not executed. Can someone point me in the direction of a solution that prompts the user when the file is opened? I look forward to hearing from you. I sincerely appreciate it in advance.
import os
import shutil
dirpath = os.path.join('C:/Path/Folder', 'Folder')
if os.path.exists(dirpath) and os.path.isdir(dirpath):
shutil.rmtree(dirpath)
print('Deleted.')
else:
print('Folder does not exist!')
messagebox.showinfo('Ok.')