home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Extra 1997 #5
/
AmigaPlus_Extra-CD_5-97.iso
/
online-tools
/
mail
/
yamtools1.7
/
redate.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-05-06
|
8KB
|
135 lines
/******************************************************************************/
/* */
/* ReDate.rexx */
/* Copyright ©1997 by Dick Whiting */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* This one changes the Date: header in a mail to the date/time that it */
/* was received. Most useful for handling mail sent by people without */
/* a valid clock. Not sure what happens if YOU don't have one. */
/* */
/* I decided to NOT use the date/timestamp of the file itself, since so */
/* many of the scripts that I have seen update it. Instead, I use the */
/* filename to determine the date and use the timestamp from the original */
/* Date: header to build the new one. This seems to be the best compromise. */
/* */
/* NOTE: This one, like my other ones, retains the date/timestamp of the */
/* original mail. */
/* */
/* NOTE: Changes won't be visible in Yam until you do an UPDATE INDEX. */
/* */
/*----------------------------------------------------------------------------*/
/* If you use YamTools you can use this one as a TYPE=ONCE to apply to mail */
/* selected one at a time from YAM, or TYPE=MAIL to do all mail selected */
/* from a YamTools list. Remember that you CAN define two buttons using */
/* same script but with different TYPES. */
/* */
/* If you don't use YamTools--why not;) */
/* */
/*----------------------------------------------------------------------------*/
/* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
/* that it will do anything productive for anyone else, etc. etc. ;-) */
/* */
/*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
/*would love a postcard from where EVER you live. */
/* */
/*Instant GEOGRAPHY lesson;) */
/* */
/* */
/*POSTCARDS: Dick Whiting */
/* 28590 S. Beavercreek Rd. */
/* Mulino, Oregon 97042 */
/* USA */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Address Bug Reports or Comments to: */
/* Dick Whiting <dwhiting@europa.com> */
/* 06 May 1997 */
/* */
/******************************************************************************/
/*
$VER: 1.0 Copyright ©1997 by Dick Whiting
$AUTHOR: Dick Whiting
$DESCRIPTION: Change Date: header in mail to the date received
*/
options results
ADDRESS YAM
if ~show('L','rexxsupport.library') then do
addlib('rexxsupport.library',0,-30)
end
/******************************************************************************/
/* Find out the necessary information about the file */
/******************************************************************************/
'getmailinfo file'
mfile=result
slpos=lastpos('/',mfile)
copos=lastpos(':',mfile)
filename=strip(substr(mfile,max(slpos,copos)+1))
parse var filename fdate '.' rest /* fn=internal date */
dow=substr(date('W',fdate,'I'),1,3) /* day of week received */
normdate=date('N',fdate,'I') /* date received */
fstate=statef(mfile) /* file information */
fbytes=subword(fstate,2,1) /* length of file */
fdate=subword(fstate,5,1) /* internal date */
fmins=subword(fstate,6,1) /* minutes since midnite*/
fticks=subword(fstate,7,1) /* ticks past minutes */
fcomm=subword(fstate,8) /* old comment */
fdate=date('E',fdate,'I') /* get date in ddmmyy */
fdate=translate(fdate,'-','/') /* convert / to - */
hh=fmins%60 /* get hours */
hh=right(hh,2,'0') /* force to 2 digits */
mm=fmins//60 /* get minutes */
mm=right(mm,2,'0') /* force to 2 digits */
ss=fticks%50 /* seconds */
ss=right(ss,2,'0') /* force it */
ftime=hh||':'||mm||':'||ss /* timestamp rebuilt */
/******************************************************************************/
/* Read the selected mail and replace the Date: header. */
/******************************************************************************/
if open('IN',mfile,'R') & open('OUT','T:fdate.tmp','W') then do
do until eof('IN')
linein=readln('IN')
if substr(linein,1,6)='Date: ' then do
copos=lastpos(':',linein) /* find last : in time */
mtime=substr(linein,copos-5) /* timestamp of sender */
datestamp='Date: '||dow||', '||normdate||' '||mtime
foo=writeln('OUT',datestamp)
do until eof('IN')
blockin=readch('IN',20480) /* grab BIG chunks now */
foo=writech('OUT',blockin)
end
signal cleanup
end
foo=writeln('OUT',linein)
end
end
CLEANUP:
/******************************************************************************/
/* Should be all done. Close files, replace mail with temp, and cleanup */
/******************************************************************************/
foo=close('IN')
foo=close('OUT')
Address Command 'SetDate T:fdate.tmp 'fdate ftime
Address Command 'Filenote T:fdate.tmp "'fcomm'"'
Address Command 'Copy T:fdate.tmp TO ' mfile 'CLONE QUIET'
Address Command 'Delete T:fdate.tmp QUIET'
exit
/******************************************************************************/
/* END OF ACTIVE CODE */
/******************************************************************************/