home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
rexxlb.zip
/
SAMPLES
/
DELCH.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-01-09
|
2KB
|
52 lines
/*****************************************************************************/
/* */
/* DELCH: Delete a file if CRCs compare. */
/* */
/* Requires Personal REXX or REXXLIB (parsefn, dosdrive, dosdel, filecrc */
/* functions). */
/* */
/* Command format: DELCH <fileid1> <fileid2> */
/* */
/* The first file is deleted if the CRCs match. */
/* */
/*****************************************************************************/
parse arg file1 file2 .
if file2 = '' then do
say 'Format is: DELCH <file1> <file2>'
exit 1
end
parse value parsefn(file1) with disk1 path1 fn1 ft1
parse value parsefn(file2) with disk2 path2 fn2 ft2
if disk1 = '-' then
disk1 = dosdrive()
if disk2 = '-' then
disk2 = disk1
if fn2 = '-' & ft2 = '-' then do
fn2 = fn1
if ft1 \= '-' then
ft2 = ft1
end
fileid1 = makefn(1)
fileid2 = makefn(2)
if filecrc(fileid1) = filecrc(fileid2) then do
say 'Files compare - deleting' fileid1
call dosdel fileid1
end
else
say 'Files are different.'
return
makefn:
arg i
path = value('path'i)
if path = '-' then
path = ''
fileid = value('disk'i)':'path
ft = value('ft'i)
if ft = '-' then
fileid = fileid||value('fn'i)
else
fileid = fileid||value('fn'i)'.'ft
return fileid