[Pythonmac-SIG] Editing files from OSX console

Jack Jansen jackjansen@mac.com
Sat, 5 May 2001 00:58:35 +0200


--Apple-Mail-487974949-1
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	format=flowed;
	charset=us-ascii

Here's a script I've been using in my OSX terminal window a lot to open 
a file with BBEdit. There's probably a better way to do this (please let 
me know!).

Oh yes: you have to change the disk name to what your disk is called. 
There's probably
a unix utility that will tell you this, but I couldn't find it. I also 
couldn't find a pathname conversion command, it's also probably 
available, please let me know if you know of something.
<Attachment missing>
--Apple-Mail-487974949-1
Content-Type: multipart/mixed;
	boundary=Apple-Mail-11357690-2


--Apple-Mail-11357690-2
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii;
	format=flowed

Here's a script I've been using in my OSX terminal window a lot to open 
a file with BBEdit. There's probably a better way to do this (please let 
me know!).

Oh yes: you have to change the disk name to what your disk is called. 
There's probably
a unix utility that will tell you this, but I couldn't find it. I also 
couldn't find a pathname conversion command, it's also probably 
available, please let me know if you know of something.

--Apple-Mail-11357690-2
Content-Disposition: attachment
Content-Type: multipart/appledouble;
	boundary=Apple-Mail-1625853867-3


--Apple-Mail-1625853867-3
Content-Disposition: attachment;
	filename="bbedit"
Content-Type: application/applefile;
	name="bbedit"
Content-Transfer-Encoding: base64

AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAJAAAAMgAAAAoAAAADAAAAPAAAAAZURVhUAAAA
AAAAYmJlZGl0

--Apple-Mail-1625853867-3
Content-Disposition: attachment;
	filename="bbedit"
Content-Type: application/octet-stream;
	name="bbedit";
	x-mac-type=54455854;
	x-mac-creator=0;
	x-unix-mode=0755
Content-Transfer-Encoding: quoted-printable

#!/usr/local/bin/python=0A#=0A#=20Open=20files=20with=20BBEdit=0A#=0A=
import=20sys=0Aimport=20os=0Aimport=20urllib=0Aimport=20macurl2path=0A=
import=20string=0A=0ASCRIPT=3D"""=0Atell=20application=20"BBEdit=206.1=20=
for=20OS=20X"=0A=09activate=0A%s=0Aend=20tell=0A"""=0ADISK=3D"/Worm"=0A=0A=
def=20main():=0A=09files=3D[]=0A=09for=20file=20in=20sys.argv[1:]:=0A=09=09=
files.append(convert2mac(file))=0A=09opencommands=20=3D=20=
string.join(map(lambda=20x:=20'\topen=20"%s"'=20%=20x,=20files),=20'\n')=0A=
=09fp=20=3D=20=20os.popen("/usr/bin/osascript",=20"w")=0A=09=
fp.write(SCRIPT=20%=20opencommands)=0A=09sys.exit(fp.close())=0A=09=0A=
def=20convert2mac(filename):=0A=09if=20not=20os.path.isabs(filename):=0A=09=
=09filename=20=3D=20os.path.join(os.getcwd(),=20filename)=0A=09filename=20=
=3D=20DISK=20+=20filename=0A=09url=20=3D=20urllib.pathname2url(filename)=0A=
=09macfilename=20=3D=20macurl2path.url2pathname(url)=0A=09return=20=
macfilename=0A=09=0Amain()=

--Apple-Mail-1625853867-3--

--Apple-Mail-11357690-2--

--Apple-Mail-487974949-1--