[Rubyosa-discuss] Finder scripting
jeanpierre at gmail.com
jeanpierre at gmail.com
Mon Oct 30 21:36:04 EST 2006
On 10/29/06, jeanpierre at gmail.com <jeanpierre at gmail.com> wrote:
> On 10/29/06, Laurent Sansonetti <lrz at chopine.be> wrote:
> > Hi Jean-Pierre,
> >
> > On Oct 29, 2006, at 9:34 PM, jeanpierre at gmail.com wrote:
> >
> > > i just cannot seem to wrap my head around using rubyosa to interact
> > > with the finder. i generated the lovely rdoc doumentation and read
> > > through it, but i am failing to understand how i would reference an
> > > arbitrary folder or file.
> > >
> > > say i want to move some file matz.png from /tmp to the user's
> > > documents folder...
> > >
> > > all i can come up with so far is:
> > > finder = OSA.app('Finder')
> > > file = '?' # somehow reference /tmp/matz.png
> > > documents = finder.home.items.select {|i| i.name == 'Documents'}
> > > file.move(documents)
> > >
> > > there must be a better way than selecting items right?
> > >
> >
> > I plan to enhance the API to make this kind of requests easier.
>
> i think a set of general file utilities could be really helpful. in
> the interim, i'll wrap wrap calls to #items to make this a bit easier.
> i haven't done much with applescript in the past so perhaps its file
> reference abilities are pretty limited in this regard?
i've managed to figure out the (bizarre) applescript syntax necessary
to pull this off:
tell application "Finder"
move alias "stable:private:tmp:matz.png" to folder "Documents" of home
end tell
now if i could only figure out how to do the following bit in rubyosa =)
alias "stable:private:tmp:matz.png"
cheers,
jean-pierre
More information about the Rubyosa-discuss
mailing list