Hello All
Saving 'base64' encoded attachments can be boring and repetitive; 'Save',
'OK' the requester and then 'Next', so I wrote this script.
For instance, if you get twenty messages each with one or more attachments,
then you high-light the first message, but do not open it. Open a shell and
type 'rx REXX:UudecodeAttach.rx 20', the script will open the first message
and then work it's way through it and the next nineteen following messages
saving all the attachments; I hope.
It's still very new so it will change. Let me know if you think it's worth
pursuing.
--- 8< -- Cut Here -- 8< ---
/*
$VER: 0.6 UudecodeAttach.rx (12-12-2000)
$AUTHOR: by Jules (JA888)© 2000
$DESCRIPTION: Unencoding attachments.
Need at least version 48 of ixemul.library.
And the Command Uudecode (on Aminet, search slrn in News/Comm)
Snoopdos (by Eddy Carroll)
Note:
This script cannot handle attachments which have been split across
more than one message.
Nor will it; as yet, save plain ASCII attachments.
Instructions:
1) If 'Snoopdos' is not in your system path, enter the new path
in this script.
2) Select but do not open the first Email or news message, as the script
will do that. (the first file will be opened with the
'READSELECTEDMSGS' command and the subsequent ones' will use the
'GotoMsg Next' command.)
3) This script should be run with a numerical argument for the number
of files to be read. Output is by default to 'RAM:'.
(rx rexx:UudecodeAttach.rx 3)
*/
OPTIONS RESULTS
PARSE ARG PICOUNT
CALL PRAGMA 'DIRECTORY','RAM:'
/*
And the path of Snoopdos. Example SNOOP="SYS:Tools/Snoopdos"
*/
SNOOP="SNOOPDOS"
/*
Check that Microdot is running
*/
IF ~SHOW('P','MD.1') THEN EXIT
/*
The counters
*/
PICOUNT=STRIP(PICOUNT)
IF PICOUNT < 1 THEN PICOUNT=1
AA=0 ; A=1
/*
Check if SnoopDos is running; if not, then start it
*/
SNOOPPATH="RUN >NIL: "||SNOOP||" HIDEMETHOD=TOOLSMENU HIDE"
IF ~SHOW('P','SNOOPDOS') THEN DO
ADDRESS COMMAND SNOOPPATH ; ADDRESS COMMAND "WAITFORPORT SNOOPDOS"
END
/*
Start of Main loop
*/
DO A=1 TO PICOUNT
/*
Set up Snoopdos
*/
ADDRESS SNOOPDOS ; ENABLE ; CLEARBUFFER ; FORMAT "%50n"
/*
Read the message in MD-II
*/
ADDRESS MD.1
IF A<2 THEN READSELECTEDMSGS
ELSE GOTOMSG NEXT
ADDRESS COMMAND 'WAIT'
ADDRESS SNOOPDOS ; SAVEBUFFER "T:SnoopMD"
ADDRESS COMMAND 'WAIT'
DISABLE ; /* Disable Snoopdos */
CALL OPEN('MD','T:SnoopMD','R')
AA=READCH('MD',125) ; AA=STRIP(AA,B)
CALL CLOSE('MD')
IF LENGTH(AA)<120 THEN DO
CALL GETOUTOFHERE ; EXIT
END
/*
Find the correct line.
*/
DETEC=0 ; PDRAW="" ; DFILE=""
CALL OPEN('MD','T:SnoopMD','R')
DO UNTIL DETEC>1
PDRAW=READLN('MD') ; DETEC=POS('DBX_',PDRAW)
IF EOF('MD')=1 THEN DO
CALL GETOUTOFHERE ; EXIT
END
END
DFILE=READLN('MD')
CALL CLOSE('MD')
/*
Give it a hair cut
*/
TARGETFILE=STRIP(PDRAW)||"/"||STRIP(DFILE)
/*
OPF = OUTPUT FILE
SUBCOUNT = Counter for the number of attachments
CC = Message path
*/
CC=TARGETFILE
CALL OPEN('TF',CC,'R')
SUBCOUNT=0
/*
Start of inner loop
*/
DO UNTIL EOF('TF')=1
SUBCOUNT=SUBCOUNT+1 ; DETEC=0 ; PDRAW="" ; DFILE=""
DO UNTIL DETEC=1
PDRAW=READLN('TF')
IF SUBSTR(PDRAW,1,9)='begin 644' THEN DETEC=1
IF SUBSTR(PDRAW,1,33)='Content-Transfer-Encoding: base64' THEN DETEC=1
IF EOF('TF')=1 THEN LEAVE
END
DETEC=0 ; OPF='T:TF'||PICOUNT||SUBCOUNT
CALL OPEN('IMAGE',OPF,'W')
CALL WRITELN('IMAGE',PDRAW)
DO UNTIL DETEC=1
PDRAW=READLN('TF') ; CALL WRITELN('IMAGE',PDRAW)
IF SUBSTR(PDRAW,1,3)='end' THEN DETEC=1
IF SUBSTR(PDRAW,1,9)='------_=_' THEN DETEC=1
IF SUBSTR(PDRAW,1,14)='--------------' THEN DETEC=1
IF EOF('TF')=1 THEN DETEC=1
END
END
/*
End of inner loop
*/
CALL CLOSE('IMAGE') ; CALL CLOSE('TF')
ADDRESS COMMAND 'C:uudecode T:TF* >NIL:'
BB=A' of 'PICOUNT' saved.' ; SAY BB
END
/*
End of Main loop
*/
SAY 'Cleaning up.'
CALL PRAGMA 'DIRECTORY','sys:'
CALL GETOUTOFHERE
ADDRESS COMMAND "C:WAIT"
SAY 'Complete.'
EXIT
GETOUTOFHERE:
ADDRESS COMMAND "C:DELETE T:SnoopMD QUIET >NIL:"
ADDRESS COMMAND "C:DELETE T:TF#? QUIET >NIL:"
ADDRESS SNOOPDOS ; QUIT
RETURN
--- 8< -- And Here -- 8< ---
--
All the best
Jules
--
Goldfish do not bounce.
-- Bart Simpson
__________________________________________________________________
MicroDot-II Mailing List - http://www.vapor.com/md2/
MicroDot-II FAQ: http://faq.vapor.com/md2/
Listserver Help: mailto:[EMAIL PROTECTED]?Subject=HELP
Unsubscribe....: mailto:[EMAIL PROTECTED]?Subject=UNSUBSCRIBE