ZTree.com  | ZEN  | About...  

 Index   Back

[OT] Batch file to check if file is open   [OT]

By: Ian Binnie   Homepage   Sydney  
Date: Feb 14,2014 at 02:25
In Response to: [OT] Batch file to check if file is open (Neil Clough)

> Hi Batch file gurus
>
> I want a batch file to check if a file is open.
>
> I found this one on DosTips.com (very good site - with a good forum).
>
> echo.N|copy /-y NUL
> "%filename%">NUL&&(
> echo.%filename% is free!
> rem leave this rem here at the block end!!!
> ) || (
> echo.%filename% is in use!
> )
>
> Works generally except for the actual file type I want to check, which
> is Excel !!
>
> Works generally here too except if the file is set as ReadOnly in
> Excel.
>
> The batch file returns that the file is free !!
>
> Thanks,

I think you are out of luck. It is quite a while since I have worked with Excel on Windows, but it handles files differently to most programs. Even if you open a file, do not change it and never save it Excel updates the internal date. I suspect Excel reads the file into its internal structure, and writes on close.

1,253 views      
Thread locked
 

Messages in this Thread

 
96,637 Postings in 12,231 Threads, 350 registered users, 61 users online (0 registered, 61 guests)
Index | Admin contact |   Forum Time: Mar 28, 2024 - 12:29 pm UTC  |  Hits:62,366,314  (18,711 Today )
RSS Feed