Tuesday, November 25, 2008

Applescript to decode Gmail's noname attachments from base64

This site does it all for you, good if you're in a hurry:
http://www.jquery.info/noname/

Below is an applescript:
You still have to open the file and remove the first blocks of MIME headers and the last line of the file. Then drop your edited noname onto it.

Can someone help me write a way to remove the MIME headers and the last line of the file... any ideas? Maybe a pattern matching a solid block of 500 chars or so with no spaces?


on open theFile
tell application "Finder"
-- get a "/folder/folder/name" (POSIX) path
set thePath to POSIX path of (theFile) as string
-- make work with spaces in the path
set theName to do shell script "perl -e \"print quotemeta ('" & thePath & "');\""
-- decode noname from base64 and save to the Desktop as somename
do shell script "/usr/bin/openssl enc -d -base64 -in " & theName & " -out ~/Desktop/noname_fix"
end tell
end open


http://drobertadams.blogspot.com/2007/12/opening-gmail-attachments-in-mac-os-x.html