• 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: shell script how to get current window path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script how to get current window path


  • Subject: Re: shell script how to get current window path
  • From: Axel Luttgens <email@hidden>
  • Date: Tue, 25 Nov 2008 09:58:09 +0100

Le 25 nov. 08 à 09:35, Quentin Arnault a écrit :

Hi,

I would like to implement an Apple script which will launch the make command
in the current path.


I tried something like:

on run
  do shell script "cd " & quoted form of the_path in window 1
  do shell script "make"
end run

But I have the following error when I run the script:
tell current application
  get quoted form of the_path of window 1
      "Can't make quoted form of the_path of window 1 of «script» into
type Unicode text."

Do you have any idea on how I can write the script to do such action ?

Hello Quentin,

There are two problems here, even if you've only met the first one yet.

Windows are handled by applications, so you need to ask the relevant application to provide you with the relevant information (hereafter, I'll assume that the application is the Finder).

On the other hand, each invocation of "do shell script" spawns its own shell process; so, cdeing in the first process won't change the second one's current directory.

As a result, something along these lines should be more effective:

on run
tell application "Finder" to get target of Finder window 1 as alias
set the_path to POSIX path of result
do shell script "cd " & quoted form of the_path & "; make"
end run


HTH,
Axel _______________________________________________
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: shell script how to get current window path
      • From: "Quentin Arnault" <email@hidden>
References: 
 >Fwd: shell script how to get current window path (From: "Quentin Arnault" <email@hidden>)

  • Prev by Date: Re: Fwd: shell script how to get current window path
  • Next by Date: Re: shell script how to get current window path
  • Previous by thread: Re: Fwd: shell script how to get current window path
  • Next by thread: Re: shell script how to get current window path
  • Index(es):
    • Date
    • Thread