home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
disks
/
tools
/
afsdefrag
/
defrag
< prev
next >
Wrap
Text File
|
1996-07-22
|
2KB
|
86 lines
/* Defrag file on an AFS disk */
/* June 19, 1996 by Kirk Strauser */
parse arg volume minf
if arg()=0 then do
say 'Usage: Defrag VOLUME: MINFRAGS'
exit
end
minf=strip(minf)
if datatype(minf)='CHAR' then minf=2
tempdir='t:'
say 'Scanning 'volume' for files with 'minf' or more fragments...'
say ' '
address command
'diskvalid '||volume||' analyse >t:temp'
if ~open(list,'t:temp','r') then do
say 'Had trouble opening the temp file.'
exit
end
a=readln(list)
if a="couldn't find device!!" then do
say "DiskValid couldn't find "volume
exit
end
if a="couldn't inhibit device" then do
say "DiskValid couldn't inhibit "volume
exit
end
a=readln(list);a=readln(list)
if a="not an afs disk" then do
say volume' is not an AFS disk.'
exit
end
if left(a,10)='read error' then do
say 'DiskValid encountered a read error on 'volume
exit
end
flag=0
do until eof(list)
a=readln(list)
parse var a o1 o2 file
if o1='fragmented' then do
file=substr(file,2)
w=words(file);w2=wordindex(file,w-1)
frag=substr(word(file,w-1),2)
file=left(file,w2-2)
l=lastpos('~',file)
if l>0 then do
file=left(file,l-1)||'*'||substr(file,l)
end
if frag>=minf then do
say 'Defragmenting: 'file' ('frag' fragments)...'
'copy "'||file||'" t:defragtempfile'
'copy t:defragtempfile "'||file||'"'
flag=flag+1
end
if frag<minf then do
say 'Skipping file: 'file' ('frag' fragments)...'
end
end
end
call close list
'delete >nil: t:temp'
if flag=0 then do
say 'No fragmented files found.'
exit
end
say 'Found and defragmented 'flag' files on 'volume'.'
'delete >nil: '||tempdir||'defragtempfile'
exit
$VER: AFSFileDefrag 1.1 (14.7.96)