home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
164.lha
/
ARexx
/
Example_ARexx
/
Reformat.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1988-04-28
|
4KB
|
128 lines
/*
A utility that will convert ARCED,ZOOED or PAKED
files into either of the other 2 formats you request
and place it beside the original file in the new compacted format.
It handles the tedious task automatically and interactively.
NB: the full path must be given for the location of
file to be converted - e.g. df1:testing/one/time.arc
Also requires that ARC,ZOO and PAK be in the C: directory.
As much error checking has been built in as possible.
August 13, 1988 - Basil 71361,2622
*/
parse upper arg x
LF='0A'x
/* establish a position for the dot suffix */
Dotposition=length(x)-3
/* check if the user has got the program call correct */
call pathcheck
/* now make the new ram: directory and copy the file to it */
if exists('ram:formatdir') then address command 'delete ram:formatdir all'
if ~exists('ram:formatdir') then address command 'makedir ram:formatdir'
address command 'copy ' x 'to ram:formatdir'
/* find out what format the user wants it to be in */
selectchoice:
say ""
say "What file format do you wish to be used for compression? "
say " 1)=ARC"
say " 2)=ZOO"
say " 3)=PAK"
say " 4)=Exit please - changed my mind"
pull fformat
select
when fformat=1 then newsuffix=".ARC"
when fformat=2 then newsuffix=".ZOO"
when fformat=3 then newsuffix=".PAK"
when fformat=4 then exit
otherwise say "Your answer must be 1, 2, 3 or 4 only"
end
if fformat<1 | fformat>3 then call selectchoice
/* now decompress the file to its components. */
if Ending='.ARC' then
do
address command 'cd ram:formatdir'LF'arc x ' file LF'delete' file
end
else if Ending='.ZOO' then
do
address command 'cd ram:formatdir'LF'zoo x ' file LF'delete' file
end
else address command 'cd ram:formatdir'LF file LF'delete' file
newfile=left(file,(length(file)-4)) || newsuffix
contents=showdir('ram:formatdir')
/* put it all together and replace it */
select
when fformat=1 then address command 'cd ram:formatdir'LF'arc a 'newfile contents
when fformat=2 then address command 'cd ram:formatdir'LF'zoo a 'newfile contents
when fformat=3 then address command 'cd ram:formatdir'LF'pak 'newfile contents
end
address command 'cd ram:formatdir'LF'copy 'newfile 'to 'path
address command 'delete ram:formatdir all'
exit
/* ********************* END OF PROGRAM ********************* */
pathcheck:
/* break the name down separately into the path and the file names */
if (lastpos('/',x) >0) | (lastpos(':',x) >0) then
do
if (lastpos('/',x) >0) then pos=lastpos('/',x)
else pos=lastpos(':',x)
path=substr(x,1,pos)
file=substr(x,pos+1)
end
/* check to see if there is an argument entered */
if (x = "") | (length(file) <=4) then
do
say ' '
say 'usage = rx pakall VOL:Arcfile.ARC'
say ' or rx pakall VOL:Zoofile.ZOO'
say ' or rx pakall VOL:Pakfile.PAK'
say ' where Arcfile.ARC/Zoofile.ZOO/Pakfile.PAK is the file to be Converted.'
say ' and VOL: is DF0: DF1: or DF2: etc (include full path)'
say ' ... the rest will be interactive.'
exit
end
/* there must be a volume added in */
if (lastpos(':',x)=0) then
do
say "You must include the volume name, e.g. 'DF1:' or 'ARC:' in the path"
exit
end
/* does the file exist? */
if ~exists(x) then
do
say x 'not found'
exit
end
/* and finally, is the correct suffix used? */
Ending=substr(x,Dotposition,4)
if ~(Ending = '.ARC' | Ending = '.ZOO' | Ending = '.PAK') then
do
say x "does not have the right suffix."
exit
end
return