aFileCopy and Locked Files

Started by keslaa, March 06, 2018, 08:49:47 AM

Previous topic - Next topic

keslaa

I have a script I am testing to backup user data to a network drive. It works fine but if it comes across a file that is locked or in use a prompt is shown to the user asking what they would like to do. At that point I can select "Do this for all current items" and click on "SKIP" and the script finishes just fine. In trying to find a way to completely automate this, I want to find a way that can skip these files after writing the name and directory in a log file so the user or Help Desk person can take care of these if needed. I am using aFileCopy and looked at the flags, but didn't see any that might do what I am looking for. I also looked at listing all files in a directory and then run the "If FileExist(BlaBlah) == 2" check, but there are sometimes tens of thousands of files to parse through and am not sure about the CPU cost for such a thing. This is an example of the code for the file copy:


flags = 0
src = "C:\Users\%BackupName%\Desktop\*.*"
targ = "\\<server>\<share name>\%BackupName%\Desktop")
aFileCopy(src,targ,flags)


Any ideas? Thanks!

td

FileExist only checks for read and read sharing permissions.  It does not check for write and write sharing permissions.  This means that it may not tell you when a destination file already exists and you don't have write permissions on the destination file.  But this may not be an issue for you.

Other than that you may want to consider combining the FOF_SILENT and FOF_NOERRORUI options in aFileCopy's flags parameter ( 4|1024).  It may or may not prevent the dialog from displaying.  Of course, even if it did, you still wouldn't have a list of uncopied files.   That would require additional processing.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

keslaa

Decided to simplify it for the user and have it close out applications before executing the file copy. Thanks!