home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
REX2U10.ZIP
/
FINDPATH.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1991-07-16
|
3KB
|
97 lines
/* Find File in a PATH Directory path */
/* version 1.0 July 15, 1991 */
/* Bob Pound */
arg filein disdir
if filein="?" then do
call help
exit
end
call Getfile(findfile)
PATH=value("path",,'OS2ENVIRONMENT')
call Displaypath
exit
/* Called Procedures */
Displaypath:
/* Display all paths of the PATH variable that contain */
/* the specified filename */
ffcount=0
sp=1
do until ep>=length(path)
ep=pos(";",path,sp)
/* if path doesn't end with ;, then a 0 value is returned */
if ep=0 then ep=length(path)+1
dir=substr(path,sp,ep-sp)
if right(dir,1)<>"\" then dir=dir||"\"
address cmd "@set z_found=0"
address cmd "@if exist" dir||findfile "set z_found=1"
found=value("z_found",,'OS2ENVIRONMENT')
if found=1 then do
ffcount=ffcount+1
if ffcount = 1 then do
firstfind=dir
say findfile "found on:"
end
say " " dir
if disdir<>"" then address cmd "@dir" dir||findfile
end
sp=ep+1
end
address cmd "@set z_found="
if ffcount=1 then saypath="path"
if ffcount>1 then saypath="paths"
if ffcount > 0 then do
say findfile "found on" ffcount saypath
if lastpos("*",findfile)=0 & lastpos("?",findfile)=0 then say findfile"in" firstfind "will be accessed first."
end
return
GETFILE:
findfile=""
do while findfile = ""
fdrive=filespec("drive",filein)
if fdrive <> "" then say "Drive not used and is ignored"
fpath=filespec("path",filein)
if fpath <> "" then say "Path not used and is ignored"
findfile=filespec("name",filein)
if findfile == "" then do
say "A valid file name is needed for this procedure"
say "Please enter a valid file name"
pull filein
end
end
return(findfile)
HELP:
say "FINDPATH will locate which directory in your current PATH"
say "environment that a specified file or mask is located in."
say " "
say "FORMAT:"
say "FINDPATH filename [D]"
say " "
say " filename - is any accetpable OS/2 file spec name. Wildcards"
say " accepted. If this parameter is missing, or invalid you"
say " prompted for a valid file name."
say " [D] - This option parameter is used if you want a directory"
say " display for the file name when it is located in"
say " a directory."
say " "
say "EXAMPLES:"
say " findpath *.cmd"
say " This will locate all directories in your PATH"
say " environment that contain *.CMD files"
say " findpath os2*.ini D"
say " This will locate all directories in your PATH"
say " environment that contain OS2*.INI files. For"
say " ever directory that has those files the"
say " procedure will display the results of a"
say " DIR OS2*.INI command."
return