home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 6 File
/
06-File.zip
/
crlist.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-02-08
|
13KB
|
286 lines
/* */
/* name: CRFLIST.CMD */
/* */
/* function: REXX script to create a file list from an image */
/* directory tree */
/* */
/* usage: CRFLIST imageDir listFile */
/* */
/* where: imageDir - fully qualified base directory for the */
/* directory tree with the images */
/* Def.: E:\OS2IMAGE */
/* */
/* listFile - name of the file for the file listing */
/* Def.: .\filelist.cd */
/* If the file already exist, CRFLIST deletes */
/* it prior to do anything! */
/* */
/* */
/* */
/* example: CRFLIST E:\OS2IMAGE WARP4CD.LST */
/* */
/* author: Bernd Schemmer */
/* Baeckerweg 48 */
/* D-60316 Frankfurt */
/* Germany */
/* EMail: 100104.613@compuserve.com */
/* */
/* history: */
/* 01.12.1996 v1.00 /bs */
/* initial release */
/* */
/* distribution: This program is freeware. */
/* */
/* notes: */
/* - works only with OS/2 installation CDs */
/* - CRFLIST assumes that all archives are packed with PACK2.EXE */
/* and do not have an extension */
/* - needs UNPACK2.EXE and RXQUEUE.EXE */
/* */
/* */
/* */
/* default values for the parameters */
DefImgDir = 'E:\OS2IMAGE'
DefListFile = '.\filelist.cd'
/* get the name of this program */
parse source . . thisFile
progName = fileSpec( 'N', thisFile )
/* get the parameter */
parse upper arg ImgDir ListFile
if pos( '?', ImgDir ListFile ) <> 0 then
do
say progName || ' - create a filelist of an OS/2 installation CD-ROM'
say
say 'Usage: ' || progName || ' {imgDir} {listFile}'
say 'where: imgDir = directory with the images'
say ' (def.: ' || defImgDir || ')'
say ' listFile = file for the filelist'
say ' (def.: ' || defListFile || ')'
say
exit 1
end /* if */
/* check the parameter */
if imgDir = '' then
imgDir = DefImgDir
if ListFile = '' then
ListFile = defListFile
/* load REXXUTIL */
call rxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
call SysLoadFuncs
/* search UNPACK.EXE */
unpackProg = SysSearchpath( 'PATH', 'UNPACK2.EXE' )
if unpackProg = '' then
do
say 'Error: Can not find UNPACK2.EXE!'
say 'Hint: UNPACK2.EXE must either in the current directory or'
say' accessbile about the PATH variable!'
exit 255
end /* if */
/* search RXQUEUE.EXE */
rxqueueProg = SysSearchPath( 'PATH', 'RXQUEUE.EXE' )
if unpackProg = '' then
do
say 'Error: Can not find RXQUEUE.EXE!'
say 'Hint: RXQUEUE.EXE must either in the current directory or'
say' accessbile about the PATH variable!'
exit 255
end /* if */
say
say 'Creating a list of the files in the OS/2 image in the directory'
say ' ' imgDir
say 'The list is written to the file '
say ' ' ListFile
say
'@del' ListFile '2>NUL 1>NUL'
call LineOut ListFile , 'Filelist of the OS/2 Image in '
call LineOUt ListFile , ' ' imgDir
call LineOut ListFile
say ' Reading the base directory structure ...'
call SysFileTree imgDir || '\*', 'baseDirs.', 'DO'
say ' ...' baseDirs.0 'directorys found.'
if baseDirs.0 = 0 then
say 'Warning: Either the directory does not exist or is empty!'
else
say ' Reading the sub directorys ...'
nLevel = 1
do i = 1 to baseDirs.0
call ReadDirectory baseDirs.i , nLevel
end /* do i = 1 to baseDirs.0 */
exit
ReadDirectory: PROCEDURE expose ListFile unpackProg rxQueueProg
parse arg curDir , nLevel
say ' Reading the directory "' || curDir || '" ...'
call SysFileTree curDir || '\*.*', 'subDir', 'BO'
do i = 1 to subDir.0
curEntry = subDir.i
if stream( curEntry, 'c', 'QUERY EXIST' ) <> '' then
do
/* entry is a file */
if FileSpec( 'E', curEntry ) = '' then
do
say ' Reading the file "' || curEntry || '" ...'
fileOK = 0
do while queued() <> 0; parse pull; end;
'@' || unpackProg curEntry '/SHOW' ' | ' rxQueueProg
do while queued() <> 0
curSubEntry = lineIn( 'QUEUE:' )
parse var curSubEntry _2Chars +2 curFileName
if _2Chars = '->' then
do
if fileOk = 0 then
do
call lineOut ListFile, copies( ' ', nLevel*2 ) || curEntry '<Archive>'
fileOK = 1
end /* if fileOK = 0 then */
call lineOut ListFile, copies( ' ',nLevel*2 ) curSubEntry
end /* if _2Chars = '->' then */
end /* do while queued() */
if fileOk = 0 then
call lineOut ListFile, copies( ' ', nLevel*2 ) || curEntry
end /* if fileSpec( 'E', curEntry ) = '' then */
else
call lineOut ListFile, copies( ' ', nLevel*2 ) || curEntry
end /* if stream( curEntry, 'c', 'QUERY EXIST' ) <> '' then */
else
do
call lineOut ListFile, copies( ' ', nLevel*2 ) || curEntry '<DIR>'
/* entry is a directory */
call ReadDirectory curEntry , nLevel + 1
end /* else */
end /* do i = 1 to subdDir.0 */
return
/* ------------------------------------------------------------------ */
/* function: Extended FILESPEC function */
/* */
/* call: FileSpec option,fileName */
/* */
/* where: option */
/* */
/* - E{xtension} */
/* return the extension of the file */
/* */
/* - B{asename} */
/* returns the name of the file without extension */
/* */
/* - H{ome] */
/* returns the fully qualified path of the file */
/* (including the drive specifier; without the trailing */
/* backslash) */
/* */
/* All other values for "option" are processed by the */
/* original FILESPEC function. */
/* */
/* fileName */
/* - name of the file */
/* */
/* returns: if option = E{xtension}: */
/* the extension of the fileName or "" if none */
/* else */
/* if option = B{asename}: */
/* the name of the file without the path and extension */
/* else */
/* the return code of the original FILESPEC function */
/* or "SYNTAX ERROR" if called with invalid parameter */
/* */
/* note: To call the original FILESPEC function direct use */
/* myResult = "FILESPEC"( option, fileName ) */
/* */
/* history: */
/* RXT&T v1.90 /bs */
/* - added the option B{asename} */
/* RXT&T v2.30 /bs */
/* - added the option H{ome} */
/* */
FileSpec: PROCEDURE
parse arg option, fileName
/* init the return code */
rc = "SYNTAX ERROR"
/* install a local error handler */
SIGNAL ON SYNTAX NAME FileSpecError
fileName = strip( fileName ) /* v2.30 */
option = translate( strip( option ) )
/* check the option code */
select
when abbrev( "EXTENSION", option ) = 1 then
do
/* process the new added option code */
i = lastPos( ".", fileName )
if i > lastPos( "\", fileName ) then
rc = substr( fileName, i+1 )
else
rc = ""
end /* when */
when abbrev( "BASENAME", option ) = 1 then /* v1.90 */
do /* v1.90 */
/* call the original FILESPEC function v1.90 */
/* to get the filename v1.90 */
rc = "FILESPEC"( "N", fileName ) /* v1.90 */
i = lastpos( ".", rc ) /* v1.90 */
if i <> 0 then /* v1.90 */
rc = substr( rc,1, i-1 ) /* v1.90 */
end /* when */ /* v1.90 */
when abbrev( "HOME", option ) = 1 then /* v2.30 */
do /* v2.30 */
rc = "FILESPEC"( "D", fileName ) ||, /* v2.30 */
"FILESPEC"( "P", fileName ) /* v2.30 */
if right( rc,1 ) = "\" then /* v2.30 */
rc = dbrright( rc,1 ) /* v2.30 */
end /* when */ /* v2.30 */
otherwise
do
/* call the original FILESPEC function */
rc = "FILESPEC"( option, fileName )
end /* otherwise */
end /* select */
FileSpecError:
RETURN rc