file.visitFolder

Syntax file.visitFolder (path, level, callback)

Params path is a legal path name to the folder over which you wish to perform callback.

level determines the level at which traversal takes place:

If level = 1 then no sub-folders are traversed.

if level = 2 then the first level of sub-folders is traversed.

if level = infinity, all sub-folders are traversed, regardless of how deeply they are nested.

callback is the address of a function to be applied to all files and sub-folders in path in accordance with the setting of level. It is a Frontier verb or a script that operates on files and/or folders.

Action Applies a callback to all files and sub-folders in a folder. Traverses the folder structure indicated by path. file.visitFolder halts if callback produces a result of false.

Returns True if the callback returns true for every file and folder; otherwise, false.

Examples file.visitFolder ("C:\\Old Stuff\\", infinity, @file.delete)

   » true


file.visitFolder ("System:Holding Bin:", infinity, @file.delete)

   » true

Note that you can't use the file.delete verb directly here, but must supply its address as a parameter because the callback must be an address.

Errors If the callback routine can't be called with a single string parameter, an error will result.

Notes file.visitFolder visits the files in a folder before the folder itself. This allows you to delete all files in a folder, before deleting the folder.

The callback must be the address of a script or verb that takes a single string parameter (the file or folder path) and returns a boolean result.

Discuss