/*************************************************************************/ /* DLIST.CMD by Steven Grim, MAY 1998 */ /* Email: reaper@mindspring.com */ /* */ /* This is a simple REXX program that lists all the local drive letters, */ /* and displays Free space, Used space, Total space, Volume label and */ /* percent full. It uses colors that you can change for your own */ /* enjoyment. This program can also be run across the network, by using */ /* the NET ADMIN command. I.E. net admin \\server /c dlist */ /* */ /* There are 2 commandline parameters: */ /* */ /* Default: Program will display both local and remote drives, with no */ /* textfile. */ /* */ /* /L Displays local drives only. */ /* */ /* /T Writes a textfile, based on the screen display. If /L is */ /* used, then only the local drives will be written. Otherwise */ /* both local and remote will be written. */ /* */ /* This program uses the ANSI codes for changing the colors. */ /* */ /* If you find this program useful, let me know by email. */ /* */ /* Revision History: */ /* */ /* 10 Aug 2003 - I update the program, to generate a plain text file */ /* when the commandline parameter /T is used. It will be */ /* called DLIST.TXT and it will be created in the default */ /* directory. */ /* */ /* 16 Aug 2003 - I added RxFMem to display the System Memory Free */ /* amount at the bottom of the screen display and text */ /* file. RXFMEM.ZIP is available at Hobbes, if you want */ /* to display the memory. You will need to un-comment */ /* some lines (9 lines) to display it. */ /* */ /* */ /*************************************************************************/ PARSE UPPER ARG TST call rxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs' call SysLoadFuncs call RxFuncAdd 'RxFreeMem','RxFMem','RxFreeMem' call color NUMERIC DIGITS 13 /* For large drives. May need to increase later. */ LocalDrive = 0 TextFile = 0 if pos('/L', TST) > 0 then LocalDrive = 1 if pos('/T', TST) > 0 then TextFile = 1 lstl = SysDriveMap('C:',LOCAL) lstu = SysDriveMap('C:',REMOTE) freephysical=RxFreeMem('Physical') fSize = FreePhysical call PutC /* Call PutC to insert commas. */ pFreeMem = FmtSize /* Fill in header of textfile. */ if TextFile = 1 then do tFile = 'DLIST.TXT' '@del' tFile '>nul' call lineout tFile, center('DLIST - Drive space LIST - By Steven Grim 1999-2003', 78) end /* Fill in header of display. */ say green say center('DLIST - Drive space LIST - By Steven Grim 1999-2003', 78) white say center('Use /L on commandline for local drives only.', 78) say center('Use /T on commandline to generate a textfile.', 78) say yellow say 'Drv Free Space Used Space Total Space Vol Label % Filled' if TextFile = 1 then do call lineout tFile, ' ' call lineout tFile, 'Drv Free Space Used Space Total Space Vol Label % Filled' call lineout tFile, copies('-',78) end say copies('ฤ',78) say ' อออออ> L O C A L D R I V E S' if TextFile = 1 then do call lineout tFile, ' =====> L O C A L D R I V E S' call lineout tFile, copies('-',78) end say copies('ฤ',78) lst = lstL call MAINLOOP /* If /L is used, then end program to only display the local drives. */ /* Otherwise, continue and display the remote drives. */ if LocalDrive = 1 then call finished say yellow say copies('ฤ',78) say ' อออออ> R E M O T E D R I V E S' say copies('ฤ',78) if TextFile = 1 then do call lineout tFile, copies('-',78) call lineout tFile, ' =====> R E M O T E D R I V E S' call lineout tFile, copies('-',78) end if lstU = '' then do say red || 'No remote drives found.' if TextFile = 1 then do call lineout tFile, 'No remote drives found.' end call finished end lst = lstU call MAINLOOP Finished: say cyan say center('Note: Overall total does not include CDROM drives (Free space = 0).', 78) basic say center('System Physical Memory free:' pFreeMem 'MB', 78) if TextFile = 1 then do call lineout tFile, ' ' call lineout tFile, center('Note: Overall total does not include CDROM drives (Free space = 0).',78) call lineout tFile, center('System Physical Memory free:' pFreeMem 'MB', 78) call lineout tFile, center('Completed at' date() time(), 78) call lineout tFile end exit MainLoop: /* This is the main subroutine. It is called twice: once for the local */ /* drives and once for the remote drives (if /L is not used.) */ lst = translate(lst,'',':') UsedT=0 TotT=0 FreeT=0 /* Break out each drive and format the data. */ do i = 1 to words(lst) /* Cycle through the drives. */ stg = sysDriveInfo(word(lst,i)) /* Pull drive info. */ parse var stg dLetter sFreeI sTotI vLab /* Break out the drive info. */ vLab = Strip(vLab, 'B') fSize = sFreeI call PutC /* Call PutC to insert commas. */ sFree = FmtSize fSize = sTotI call PutC /* Call PutC to insert commas. */ sTot = FmtSize SELECT WHEN sFreeI = 0 & sTotI > 0 THEN do /* Either a full disk or a CD */ pct = '100.00% Full' /* disk. */ sUsedI = sTotI fSize = sUsedI call PutC /* Call PutC to insert commas. */ sUsed = FmtSize END WHEN sFreeI = '' | sTotI = '' THEN do /* probably a CD, JAZ, or ZIP drive */ pct = 'N/A' /* with no disk in the drive. */ sUsed = '' dLetter = word(lst,i) || ':' /* Still puts drive letter in Display. */ END OTHERWISE do sUsedI = sTotI - sFreeI UsedT = UsedT + sUsedI TotT = TotT + sTotI FreeT = FreeT + sFreeI fSize = sUsedI call PutC /* Call PutC to insert commas. */ sUsed = FmtSize pct = (sUsedI / sTotI) * 100 pct = Format(pct, 3, 2) pct = pct || '% Full' END END SAY white || dLetter normal || green || Right(sFree, 15) red || Right(sUsed, 15) yellow || Right(sTot, 15) white || Right(vLab,12) cyan || Right(pct,14) if TextFile = 1 then do call lineout tFile, dLetter Right(sFree, 15) Right(sUsed, 15) Right(sTot, 15) Right(vLab,12) Right(pct,14) end END say yellow || copies('อ',78) if TextFile = 1 then do call lineout tFile, copies('=',78) end Tpct = (usedT / TotT) * 100 Tpct = Format(Tpct, 3, 2) Tpct = Tpct || '% Full' fSize = UsedT call PutC /* Call PutC to insert commas. */ TotalUsed = FmtSize fSize = TotT call PutC /* Call PutC to insert commas. */ TotalTot = FmtSize fSize = FreeT call PutC /* Call PutC to insert commas. */ TotalFree = FmtSize SAY white || '**' green || Right(TotalFree,15) red || Right(TotalUsed, 15) yellow || Right(TotalTot, 15) white || ' Overall Tot' cyan || Right(Tpct, 14) if TextFile = 1 then do call lineout tFile, '**' Right(TotalFree,15) Right(TotalUsed, 15) Right(TotalTot, 15) ' Overall Tot' Right(Tpct, 14) end RETURN Exit PutC: /* Format the total size of all the files, by adding commas. */ fmtSize = '' IF Length(fSize) >= 10 THEN /* Billions */ DO leadSize = Length(fSize) - 9 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 9) END IF Length(fSize) >= 7 THEN /* Millions */ DO leadSize = Length(fSize) - 6 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 6) END IF Length(fSize) >= 4 THEN /* Thousands */ DO leadSize = Length(fSize) - 3 fmtSize = fmtSize || Left(fSize, leadSize)',' fSize = Right(fSize, 3) END fmtSize = fmtSize || fSize RETURN Color: /* Color setup. Use what you want. Color table is as follows: */ /* */ /* Color ForeGround BackGround */ /****************************************** */ /* Black 30 40 */ /* Red 31 41 */ /* Green 32 42 */ /* Yellow 33 43 */ /* Blue 34 44 */ /* Magenta 35 45 */ /* Cyan 36 46 */ /* White 37 47 */ /* */ /* Use [1m for bright colors, and [0m for normal colors. */ basic = '' blink = '' normal = '' bright = '' /* All colors are highlighted on BLACK background. */ red = '' green = '' yellow = '' blue = '' magenta = '' cyan = '' white = '' /* Resets color back to default of White */ /* (light gray) on Black, for those systems */ /* with default PROMPT statements. If you */ /* have a prompt statement in CONFIG, then */ /* this will not reset it. My PROMPT in my */ /* CONFIG.SYS: */ /* PROMPT=$E[1m$E[33;41m[$p]$E[1m$E[37;40m */ /* Drive letter and path - Yellow on Red, and */ /* screen is Bright White on Blue. */ /* Enjoy. */ return