home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
addupeas.zip
/
ADDUPEAS.CMD
Wrap
OS/2 REXX Batch file
|
1995-04-30
|
6KB
|
140 lines
/* ADDUPEAS.CMD This REXX program looks at specified drive */
/* and lists all files to determine the total amount of */
/* EA space that should be used on the drive in file */
/* EA DATA. SF given that each EA takes one cluster of */
/* a FAT formatted disk. This will not match exactly the */
/* size of the EA file since ... well I don't know why but */
/* it consistently reports one less cluster on my system */
/* than the size of EA DATA. SF really is. */
/* Author Trevor Hemsley - 95/04/30 */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
inputfile = "C:\temp\filelist.txt" /* this is the file to DIR to */
outputfile = "C:\temp\ealist.txt" /* file to contain the list */
file_with_ea = 0 /* initialise counter */
ea_amounts = 0 /* initialise counter */
rx = SysFileTree("C:\TEMP",rx.,"D") /* test existence of temp dir*/
if rx.0 = 0 then
do
say "Directory C:\TEMP does not exist. Create it Y/N?"
parse upper pull answer
if answer ¬= "Y" then exit
else
do
"@MD C:\TEMP"
end
end
rx = stream(inputfile,"c","query exists") /* test existence of file */
if rx ¬= "" then /* to stop from overwriting */
do
say "Warning - existing file "inputfile" will be overwritten. Continue Y/N?"
parse upper pull answer
if answer ¬= "Y" then exit
else
"@del "inputfile
end
rx = stream(outputfile,"c","query exists") /* test existence of file */
if rx ¬= "" then
do
say "Warning - existing file "outputfile" will be overwritten. Continue Y/N?"
parse upper pull answer
if answer ¬= "Y" then exit
else
"@del "outputfile
end
do while drive_letter = "DRIVE_LETTER" /* Ask which drive to process */
say "Which disk drive letter do you wish to examine (eg C) ?"
pull drive_letter
if length(drive_letter) = 1 then
do
drive_letter=drive_letter||":"
end
else
if length(drive_letter) > 2 then
do
say "Drive letter must not be more than two characters (EG C:)"
drive_letter = "DRIVE_LETTER"
end
end
disk_info = sysdriveinfo(drive_letter)
disk_size = word(disk_info,3)
real_size = stream(drive_letter"\EA DATA. SF","c","Query size")
if real_size = "" then
do
say "Could not find file EA DATA. SF - this must be run against a FAT disk"
exit
end
if disk_size > 64*1024*1024 then cluster_size=2048
if disk_size > 128*1024*1024 then cluster_size=4096
if disk_size > 256*1024*1024 then cluster_size=8192
if disk_size > 512*1024*1024 then cluster_size=16384
if disk_size > 1024*1024*1024 then cluster_size=32768
say "Total size of drive "word(disk_info,1)" is "disk_size
say "Cluster size of disk "word(disk_info,1)" is "cluster_size
say "Listing file information from "word(disk_info,1)". Please wait..."
"@dir "drive_letter"\ /a /s /n >"inputfile
if rc¬=0 then
do
say "Non-zero return code ("rc") from DIR. Ending Rexx exec."
exit
end
say "Now checking for EA's. This may take some time..."
do while lines(inputfile) ¬= 0 /* repeat for each line in input file */
rx = linein(inputfile) /* read next record from input file */
if words(rx) = 0 then iterate /* ignore blank lines */
if word(rx,1) = "The" then iterate /* ignore all lines that meet the... */
if word(rx,1) = "Directory" then iterate /* ...criteria listed here */
if word(rx,2) = "file(s)" then iterate
if word(rx,2) = "files" then iterate
if word(rx,2) = "bytes" then iterate
if word(rx,4) = 0 then iterate
else
do /* this line is for a file with EA's */
file_with_ea = file_with_ea + 1 /* add 1 to count of files found */
ry = LINEOUT(outputfile,rx) /* write this line to output file */
ea_amount=word(rx,4) /* extract size of EA's for this file*/
if ea_amount//cluster_size = 0 then /* determine how many... */
this_file_ea=(ea_amount%cluster_size) /* clusters the EA's take up */
else
this_file_ea=(ea_amount%cluster_size)+1 /* round up cluster numbers */
ea_amounts=ea_amounts+this_file_ea /* keep running total */
end /* end of DO word(rx,4) = 0 */
end
Say " "
Say "Total files with EA's found "file_with_ea
Say "Total size of EA DATA. SF will be approximately "ea_amounts*cluster_size
size_difference = real_size-(ea_amounts*cluster_size)
Say " "
Say "Difference between calculated size and actual size is "size_difference
If size_difference/cluster_size < 2 then
say "This is probably nothing to worry about ! (I mean it's normal)"
else
say "You may want to run CHKDSK "drive_letter" /F against this drive to double check."
z = stream(inputfile,"c",close) /* close input file */
z = stream(outputfile,"c",close) /* close output file */
"@del "inputfile /* clean up after us */
Say "List of files with EA's is in "outputfile ". Do you wish to keep this?"
parse upper pull answer
if answer = "Y" | answer ="YES" then
do
Say "Sorting file into EA size order ..."
"@sort /+32 /R <"outputfile" >"inputfile
"@del "outputfile
"@copy "inputfile" "outputfile" >nul"
"@del "inputfile
exit
end
else "@del "outputfile