• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Applescript and referring to a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 11:51:00 +0000

Aliases on disk and aliases in AS are different beasts.

Deep joy - that's cleared up a lot of confusion.

The Finder
wants the latter as the location of the former.  You can get an AS
alias by adding " as alias" at the end of whatever you're using to
choose the folder, e.g.

set targetFolder to (POSIX file "/path/to/target") as alias

then you can use targetFolder as the location in a 'tell application
"Finder" to make new alias' statement.

Okay, thanks for that tip.

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
    end tell

    set this_documentX to path of this_document as string
    set this_documentM to this_documentX

    tell application "Finder"
      make new alias at selected_folder to POSIX file this_documentX
      #make new alias at selected_folder to this_documentF
    end tell

  end repeat
end tell

which works, for a given value of `works', but what I managed to cobble together is very plainly VERY ugly - is there a way of *not* having to go via a POSIX view of the world to turn `this documentX' into a Finder-comprehensible file system pointer?

Cheers,
Rowland.

On Monday, January 25, 2010, Rowland McDonnell
<email@hidden> wrote:

Try this:

(In this case destinationFolder has been coerced to an alias)


I'm not sure I understand what that means.  I want to /create/ an alias in a particular folder -
that folder being identified by the contents of the variable destinationFolder in your code example.

I don't know how to fill the variable destinationFolder with data that Applescript will accept as a
reference to a folder - I just get errors.


tell application "Finder"

make new alias to POSIX file thisDocumentX at destinationFolder

end tell


The problem is that I don't know how to make the variable destinationFolder into a suitable data
type.

I just get error messages no matter what I try.

Can someone please show me how to tell Applescript to make an alias to a particular file in a
particular folder?

The bit that I cannot work out myself is how to refer to files and folders using Applescript
variables.

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



_______________________________________________ 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
  • Follow-Ups:
    • Re: Applescript and referring to a folder
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Applescript and referring to a folder (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: "Open for access weirdness"
  • Next by Date: Re: Applescript and referring to a folder
  • Previous by thread: Re: Applescript and referring to a folder
  • Next by thread: Re: Applescript and referring to a folder
  • Index(es):
    • Date
    • Thread