Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine if file is currently open???

Status
Not open for further replies.

theniteowl

Programmer
May 24, 2005
1,975
US
Is there a way in a VBS script to determine if a file is already open?

I need to move files from one server to another but files are frequently being written into the original folder and I have to know the file I am copying is not currently being written to.

My thought was to read the last modified data and ignore any files that have been modified within the last couple of minutes. It would be far better if I had some way of determining the current state of the file though.

Anyone?

Also, when I move the files they will be going from a Unix box to a Windows box. I need to make sure the file actually arrives whole at the destination before deleting it from the source. Any thoughts on best methods?
Will VBS wait for a response from the copy command before continuing to the next step or do I have to handle it another way? If it waits for a response code I can test for an error and if none found perform the delete.

Thanks.

At my age I still learn something new every day, but I forget two others.
 
Why not using robocopy ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Robocopy does not seem to have the ability to determine the age of the file within seconds or minutes, only within days.
Also, all of our servers do not have Robocopy installed and it is a lengthy process to get approval for the software install.


At my age I still learn something new every day, but I forget two others.
 
Thanks but unfortunately this approach will not work for me.
The script runs on a Win 2003 server but the source location for the files is on a Unix box and LanManServer wont pick up the file information from the foreign file system.

I have found no methods for doing this on the Unix server side either so I am back to testing the LastModified property of the files and just going with a set amount of time since the file was last written to. Not ideal but better than previous methods where they would write the list of files to a text file then parse the text file to check the file date.


At my age I still learn something new every day, but I forget two others.
 
If the unix box is a samba server you may consider the smbstatus command.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I dont think it is using Samba just has a NFS formatted drive and the Windows box has support for accessing it.

If I were to use a Unix based command though I would have to write a script to run native onthe Unix box and it gets a little too far outside my experience.

At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top