Re: Applescript and referring to a folder
Re: Applescript and referring to a folder
- Subject: Re: Applescript and referring to a folder
- From: Rowland McDonnell <email@hidden>
- Date: Tue, 26 Jan 2010 12:50:27 +0000
Rowland McDonnell <email@hidden> wrote:
What I got working myself looked like this - in terms of identifying and
selecting the file system objects I'm working with.
tell application "Finder"
if not (exists folder "TeXShop_aliases_test" of home) then
make new folder at home with properties {name:"TeXShop_aliases_test"}
end if
set selected_folder to folder "TeXShop_aliases_test" of home
end tell
tell application "TeXShop"
repeat with this_document in documents
tell application "Finder"
set this_documentF to this_document
OK, so what you have in "this_document" is a TeXShop document object.
It's not a file object, alias, or anything else having to do with the
file system.
I'm not sure I understand that - it's a pointer to an object,
and that object has a path which I manipulated in my script
using stuff I wrote.
So it's clearly an object that uniquely points to a unique file
system object.
And that sounds like a file system pointer to me, or at least
something which Applescript should coerce into such if needed,
when needed, without user interference (if what Apple says about
Applescript is true, from my reading anyway).
I have learnt: It Doesn't Work Like That.
But I don't understand why not and I don't understand how you
can say it's not got anything to do with the file system,
because I actually use the file system path of the objects concerned.
And I see Applescript complaining that it can't coerce what's
obviously a path to file system object into an alias at times.
It's all a bit strange and I don't really understand the
messages at all - they don't seem to make any sense.
So you'll have to look at what the TeXShop dictionary
provides; you may be able to get the associated document file as an
alias directly. Maybe "set this_documentA to this_document as alias"
will even work. It just depends on TeXShop.
Umm - could you perhaps give me a bit more of a hint?
tell application "Finder"
set this_documentF to this_document
end tell
Wrapping the assignment in a tell block doesn't change its meaning;
this_documentF and this_document wind up identical.
<shrug> I was trying things at random, see what worked. I've
got no understanding of how Applescript goes about this sort of thing.
set this_documentX to path of this_document as string
That is currently where you're going from TeXShop's idea of a
"document" back to something that has to do with the filesystem.
Yes, I know. I was wondering if there was a more elegant way of
doing the job, since Applescript is supposed to coerce data into
the right type without user intervention, and since it's clearly
very easy to get a file system pointer from a file system path...
<shrug>
But if no-one can come up with anything more elegant than the
mess I created myself, I'll stick with the mess.
It does after all work in a fashion that is comprehensible.
Ugly, inelegant, probably inefficient - but it works and I can
sort of understand it.
Cheers,
Rowland.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden