Deleting a folder that is locked

Hi everybody :smile:
Is there any way, in an actionscript, to check if a folder is locked by a process (there are no files inside) and avoid the error on ā€œfolder deleteā€ command?
Thanks :wink:

How about something like:

continue if {(number of folders of it + number of files of it) of folder ā€œC:\tempā€ = 0}

You would likely need to use an action with a program or script or command that can delete locked folders instead of using folder delete.

So it seems that thereā€™s no way to check if a folder is locked ?

There should be through relevance, but Iā€™m not certain. It should definitely be possible with a script or EXE of some sort.

Ah, I misunderstood the initial request (i thought we were looking for empty folder conditions, but this makes much more sense now). There is no way to do this via relevance as far as I know, but there are a number of utilities that can assist. Assuming this is Windows, you should be able to leverage the following utility to search for open handles containing the given folder:

1 Like

I would use the ā€˜dosā€™ command in actionscript. This will attempt to delete the folder, but will not error out if the folder cannot be deleted due to a lock:

dos rmdir /s /q c:\my\folder\name
2 Likes

Thanks Jason. Itā€™s exactly what we have done:-)