Wednesday, December 13, 2017

#1 2005-10-12 02:33:34 pm

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How can I tell if a file is busy?

If you want to incorporate a check in your script to determine if a file is busy, you can check the busy status property using the info for command, from Standard Additions, born in AppleScript 1.4, OS 9.

Applescript:

busy status of (info for alias "MacHD:some file.txt")

Some times, "busy status" will return "false", when it should be "true" (under some special circumstances). You can try then:

Applescript:

try
   open for access file x
   --> file is not busy (ie, it's not locked and you can write data to it)
   close access result
on error
   --> file is busy
end try

For previous versions of operative systems, use the fileIsBusy command from Jon's Commands. The scripting addition returns true if the file is currently open and false if the file is not currently open. For example,

Applescript:

fileIsBusy alias "MacHD:some file.txt"

This returns false if not running, true if it is.

If you are still sure the file is opened, and none of these methods seems to return a "true" value, you can use the *nix tool "lsof", which will return a list of all busy files in the system.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)