Find or enumerate files

Obsolete. Use FileExists. To create code, use dialog "If file exists" or "Get file info" or "Enumerate files".

 

Syntax

lpstr dir([file] [flags])

 

Parameters

file - file, folder or drive.

flags:

0 Find only files.
1 Find only folders and drives.
2 Find all.
3 If flags is 3 or omitted, uses flags used with dir previously (in current function).

 

Remarks

If the file exists, returns its filename with extension. Else returns 0.

 

See also: str.searchpath, special folders

 

Examples

 If file exists:
if(dir("$desktop$\test.txt"))
	out "file exists"

 .txt files in desktop folder:
lpstr s=dir("$desktop$\*.txt")
rep
	if(s = 0) break
	out s
	s = dir

 Folders in c:\windows:
lpstr s=dir("c:\windows\*" 1)
rep
	if(s = 0) break
	out s
	s = dir

 Drives:
Wsh.FileSystemObject fso._create
Wsh.Drive dr
foreach dr fso.Drives
	out dr.Path
	out dr.DriveType ;;0 unknown, 1 removable, 2 fixed, 3 network, 4 CD-ROM, 5 RAM disk