May-08-2020, 05:05 PM
Hello all,
I am writing a script that updates a directory with a folder structure filled with PDFs. We would like to run this script to update the PDFs each weekend to keep the data up to date. All of files are stored on a server. A large number of computers will have access to view these files and open them (not edit). Everything is working great except for one bug.
If the script runs while someone has the file open it will error out. This is because the script is designed to delete all of the "old" files and then recreate the new ones based on the database it pulls from. When the user has the PDF open windows is blocking me from deleting the file. (using shutil.rmtree)
Is there a way to still delete a file if a user has the file open or is there a way to force the users file to close so this can execute? We would like to avoid leaving the old file in the mix with an error handler as having old versions of the PDF's available would create major problems for the business.
Not sure if this was clear but I would appreciate any help as I am totally stuck on this.
Thanks
I am writing a script that updates a directory with a folder structure filled with PDFs. We would like to run this script to update the PDFs each weekend to keep the data up to date. All of files are stored on a server. A large number of computers will have access to view these files and open them (not edit). Everything is working great except for one bug.
If the script runs while someone has the file open it will error out. This is because the script is designed to delete all of the "old" files and then recreate the new ones based on the database it pulls from. When the user has the PDF open windows is blocking me from deleting the file. (using shutil.rmtree)
Is there a way to still delete a file if a user has the file open or is there a way to force the users file to close so this can execute? We would like to avoid leaving the old file in the mix with an error handler as having old versions of the PDF's available would create major problems for the business.
Not sure if this was clear but I would appreciate any help as I am totally stuck on this.
Thanks