home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
035
/
perf31.zip
/
perf_30
/
SIMPLBAK.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-01-06
|
10KB
|
327 lines
/* Simple Backup*/
/*Copyright (c) 1993 CLEAR & SIMPLE, INC.*/
ECHO OFF
arg directory destination frequency
if directory='' | destination ='' then do
Say 'The format of SimpleBAK is:'
say;say ' SimplBAK directory destination '
say;say 'Please refer to PLUS documentation, and repeat.'
say 'SimplBAK use is most effective when setup with SetUPlus.Cmd'
say;say 'Press Enter to end...'; pull
exit
end /* Do */
parse upper var destination driv '\' rest .
FromDrive=left(directory,2)
if frequency='' then frequency=0
if right(directory,1)='\' then directory=strip(directory,'T','\')
say 'Copyright (c) 1994 CLEAR & SIMPLE, INC.';say;
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
today=date('U')
parse var today month '/' day '/' year
call julian year month day
todayJulian=result
call FatOrHpfs
call getBackupDate
call szdisk driv
parse var result tofree .
call dirsize directory
parse var result SizeOfFiles NumberOfFiles
if SizeOfFiles < toFree then call copyall
else call copypart
exit
copyall:
say 'Copying 'NumberofFiles 'Files'
do j=1 to NumberofFiles
call copyfile
end /* do */
return
copypart:
say 'Copying 'NumberofFiles 'Files'
if driv='A:' | driv='B:' then diskette=1
else diskette=0
if diskette then do
say 'There are 'NumberOfFiles 'Files to be backed up'
say 'They require 'SizeOfFiles 'free space on the diskette in 'driv' drive'
Say 'The diskette only has 'tofree' space available'
say 'Would you like to proceed with this diskette - type "Y"'
say ' or use a new diskette Type "N"?'
pull newdiskette
if newdiskette ='N' then do
say 'Insert a new diskette - Press Enter to proceed';pull
call mmd destination 'y'
call szdisk driv
parse var result tofree .
end /* newdiskette Do */
do j=1 to dirs.0
if filesize.j<tofree then do
call copyfile
tofree=tofree-filesize.j
end /*copyfile*/
else do
do while tofree < filesize.j
call szdisk driv
parse var result tofree .
say 'There''s not enough room on the diskette for the next file'
say 'The File Name is = 'dirs.j ' The file size is ='filesize.j
say 'Diskette free space total is = 'tofree
say 'There are ' filecount-j 'Files remaining to be copied'
say 'Insert a new diskette - Press Enter to proceed';pull
call szdisk driv
parse var result tofree .
end /* While tofree is smaller than filesize */
call mmd destination 'y'
call copyfile
end /* do */
end /* j loop do */
end /* diskette = 1 Do */
else do
say 'There is not enough room in the destination'
say ' - ' destination 'Free Space=' tofree
say 'There are 'dirs.0 'files to be copied - they require 'SizeOfFiles 'Space'
Say 'Either change your destination 'destination ' or change the Frequency of backup' frequency
exit
end /* not a diskette Do */
return
copyfile:
fdestination=destination
dirlen=lastpos('\',dirs.j)-3
fullDir.j=substr(dirs.j,4,dirlen)
fullDir.j=strip(fullDir.j,'T','\')
if fatalert then do
parse var fulldir.j '\' s.1 '\' s.2 '\' s.3 '\' s.4 '\' s.5 '\' s.6 '\' s.7 '\' s.8 '\' s.9 '\' s.10 '\' s.11 '\' s.12 '\' s.13 '\' s.14 '\' s.15 '\' s.16 '\' s.17 '\' s.18 '\' s.19 '\' s.20
h=1
fulldir.j=''
do while s.h \= ''
parse var s.h dname '.' dext
dname=left(dname,8)
dname=strip(dname)
fulldir.j=fulldir.j'\'dname
if dext \='' then do
dext=left(dext,3)
dext=strip(dext)
fulldir.j=fulldir.j'.'dext
end /* Do */
h=h+1
end /* do while */
end /* Fat Alert Do */
call mmd destination||fulldir.j 'y'
fdestination=destination||fulldir.j
if FatAlert then do
dirlen=lastpos('\',dirs.j)
fullDir.j=left(dirs.j,dirlen)
parse var filename.j first'.'ext'.'addl
if length(first) > 8 | length(ext) >3 | addl \='' then long=1
else long=0
shortn.j=left(first,8)
shortn.j=strip(shortn.j)
shortext.j=left(ext,3)
shortext.j=strip(shortext.j)
if long then do
duplicatecheck:
k=j-1
do while k>0
dirlen=lastpos('\',dirs.k)
fullDir.k=left(dirs.k,dirlen)
if fulldir.k=fulldir.j then do
if shortn.k=shortn.j then do
if datatype(shortext.k,N) then do;shortext.j=1+shortext.k;k=0;end
else do; shortext.j=1;k=0; end
end /* dup shortn Do */
k=k-1;
end /* fulldir do */
else k=0; /* there are no duplicates in this directory */
end /* K do */
fdestination=fdestination'\'shortn.j
if shortext.j \= '' then fdestination=fdestination'.'shortext.j
end /* long Do */
end /* FAT Drive Do */
fdestination='"'fdestination'"'
say 'Copying ...'dirs.j 'to' fdestination
'copy ' dirs.j fdestination '>nul'
return
dirsize:
newq= RXQUEUE('create')
oq=RXQUEUE('Set', newq)
totalsize=0;filecount=0
'Dir ' directory '/s/n/o:-d | rxqueue 'newq
do until queued() = 0
entry=lineIN('Queue:')
parse var entry filedate ftime fsize easize name
name=strip(name,L)
fmo='';fday='';fyr='';
parse upper var filedate fmo '-' fday '-' fyr;
if fyr ='' then do;
if translate(filedate)='DIRECTORY' then directory=fsize
iterate
end /* fyr */
else do /*Date & Time Convert*/
call julian fyr fmo fday
jdate=result
if jdate=bakdate then do
parse var ftime hr ':' min
if right(min,1)='p' then hr=hr+12
fileTime=hr'.'left(min,2)
if filetime > baktime then jdate=jdate+1
end /* jdate=bakdate */
end /* Date & time convert */
if jdate > bakdate+frequency then do;
if datatype(fsize,N) then do;
totalsize=totalsize+fsize+easize;
filecount=filecount+1
dirs.filecount='"'directory'\'name'"'
filename.filecount=name;
filesize.filecount=fsize+easize
end /* datatype */
else totalsize=totalsize+easize
end /* frequency */
else call dirsearch /* no more in this directory */
end /* do queued() */
rc=rxqueue('delete', newQ)
dirs.0=filecount
return totalsize filecount
dirsearch:
do until strip(filedate)='DIRECTORY' | queued()=0
entry=lineIN('Queue:')
parse upper var entry filedate ftime fsize easize name;
if strip(filedate)='DIRECTORY' then directory=fsize
end
return
getBackupDate:
parse var directory fromdrive'\'fromdir
newdir=destination'\'fromdir
parse var newdir todirdrive'\'newdir
newdir='\'newdir
/*
if fatalert then do
parse var newdir '\' d.1 '\' d.2 '\' d.3 '\' d.4 '\' d.5 '\' d.6 '\' d.7 '\' d.8 '\' d.9 '\' d.10 '\' d.11 '\' d.12 '\' d.13 '\' d.14 '\' d.15 '\' d.16 '\' d.17 '\' d.18 '\' d.19 '\' d.20
f=1
newdir=''
do while d.f \= ''
parse var d.f dxname '.' dxext
dxname=left(dxname,8)
dxname=strip(dxname)
newdir=newdir'\'dxname
if dxext \='' then do
dxext=left(dxext,3)
dxext=strip(dxext)
newdir=newdir'.'dxext
end /* Do */
f=f+1
end /* do while */
end /* Fat Alert Do */
newdir=todirdrive||newdir
call mmd newdir 'Y'
*/
if lines(directory'\p21pbak') = 0 then
do; bakdate=todayjulian; baktime=0;end
else do; do until lines(directory'\p21pbak') = 0
parse value linein(directory'\p21pbak') with bakdate baktime .
end /*until do */
if bakdate='' then do;bakdate=todayjulian;baktime=0;end
call lineout directory'\p21pbak'
end /*else do*/
parse value time('N') with nowhr ':' nowmin ':' nowsec
nowtime=nowhr'.'nowmin
datetime= todayjulian nowtime
call lineout directory'\p21pbak',todayjulian nowtime '-' month'/'day'/'year
call lineout directory'\p21pbak'
/*
if result then do; bakdate=todayjulian; baktime=0;end
else do
nobakdate=0
do until lines(newdir'\p21pbak') = 0
parse value linein(newdir'\p21pbak') with bakdate baktime
end /*until*/
if bakdate='' then do;bakdate=todayjulian;baktime=0;end
call lineout newdir'\p21pbak'
end /* else do */
parse value time('N') with nowhr ':' nowmin ':' nowsec
nowtime=nowhr'.'nowmin
datetime= todayjulian nowtime
call lineout newdir'\p21pbak',todayjulian nowtime
*/
return
FatOrHpfs:
rc=SysMkDir(FromDrive'\'muchtoolargeforFAT)
if rc=206 then do; FatAlert=0; return; end
else DO; FromHPFS=1; call SysRmDir(drive'\'muchtoolargeforfat);END
rc=SysMkDir(destination'\'muchtoolargeforFAT)
if rc=206 then FatAlert=1
else DO; FatAlert=0; call SysRmDir(drive'\'muchtoolargeforfat);END
RETURN
julian:
arg cyear cmonth cday
cmonth=strip(cmonth,'L',0)
if cyear // 4=0 & cyear // 200 \=0 then leap=1
else leap=0
mo.1=0
mo.2=31
mo.3=59+leap
mo.4=90+leap
mo.5=120+leap
mo.6=151+leap
mo.7=181+leap
mo.8=212+leap
mo.9=243+leap
mo.10=273+leap
mo.11=304+leap
mo.12=334+leap
DofYr=mo.cmonth+cday
if length(DofYr)=1 then dofyr='00'||dofyr
else if length(DofYr)=2 then dofyr='0'||dofyr
else if length(DofYr)\=3 then do; say date error; exit; end
jdate=right(cyear,2)||DofYr
return jdate