water Posted July 17, 2009 Posted July 17, 2009 (edited) Hi AutoIt Gurus, I have the following problem: An external program creates a PDF-file (~900KB) in a directory. My script checks for this file and when it exists it moves the file do another directory with a different name. Now I have a reproducible situation where I get an error from FileMove. When I wait a few seconds after I detect the file the script runs fine. I think FileExists tells me "file found" even when the file is still being written by the other application. Therefore the error when moving the file. What is the best way to tell that the file has been closed by the other application? Thanks for your help in advance! Edited July 18, 2009 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
GEOSoft Posted July 17, 2009 Posted July 17, 2009 On 7/17/2009 at 1:43 PM, 'water said: Hi AutoIt Gurus,I have the following problem:An external program creates a PDF-file (~900KB) in a directory. My script checks for this file and when it exists it moves the file do another directory with a different name. Now I have a reproducible situation where I get an error from FileMove. When I wait a few seconds after I detect the file the script runs fine. I think FileExists tells me "file found" even when the file is still being written by the other application. Therefore the error when moving the file.What is the best way to tell that the file has been closed by the other application?Thanks for your help in advance!You can't move a file that is in use (open) by another program. If you know the size of the file then you wight want to check with FileGetSize() instead of FileExists(). Or if the external program closes after creating the file then use ProcessExists() to see if it's moveable yet or not. There are several methods of checking for what you need. George Reveal hidden contents Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
water Posted July 17, 2009 Author Posted July 17, 2009 (edited) Thanks for your reply! Unfortunately I don't know the size of the file. It was just an example and the size varies. The external program is running on another machine (a server that converts print files to pdf) so I can't check the process. I was thinking of some code to check wether someone else has the file open for reading or writing. Edited July 17, 2009 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Prab Posted July 17, 2009 Posted July 17, 2009 Not 100% sure, but try FileOpen("Name", 1). I believe it will fail if the file is still being written to. FolderLog GuiSpeech Assist
Developers Jos Posted July 17, 2009 Developers Posted July 17, 2009 You could check for the modification date/time that its at least xx seconds old so you can safely assume the writing is done ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
water Posted July 18, 2009 Author Posted July 18, 2009 Thanks a lot for your replies! I'll try the FileOpen approach. My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now