• 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: How to close finder window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to close finder window


  • Subject: Re: How to close finder window
  • From: Matthew Smith <email@hidden>
  • Date: Fri, 03 Jun 2005 08:18:24 +0800

on 03/06/2005 08:05, Mark Pauley at email@hidden wrote:

> AppleScripts don't really know they can be run with arguments...
> But we're geeks and we want/need this stuff to happen.
> I have done this before by using AppleScript in a here-document in perl:
>
> ***
> #! /usr/bin/perl -w
>
> $windowName = $ARGV[0];
>
> my $appleScript = <<"END_S";
>      tell application "Finder"
>          set theWindows to (get every Finder window)
>          repeat with eachWindow in theWindows
>              if (target of eachWindow as text) begins with
> "$windowName" then
>                  close eachWindow
>              end if
>          end repeat
>      end tell
> END_S
>
> my $returnVal;
> chomp($returnVal = `osascript -ss -e '$appleScript'`);
> print $returnVal, "\n";
>
> ***
>
> Bammo, close windows from the terminal!
>
> Unfortunately this requires forking a new process.  I would recommend
> looking into using AppleEvents to do something like this, AppleScript
> is just an easy way to send AppleEvents.

The osascript command in Mac OS X 10.4 can now handle arguments.

>From the man page:

Any arguments following the script will be passed as a list of strings to
the direct parameter of the ``run'' handler.  For example:

 a.scpt:
 on run argv
    return "hello, " & item 1 of argv & "."
 end run

% osascript a.scpt world
hello, world.

--
Matthew Smith


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: How to close finder window (From: Mark Pauley <email@hidden>)

  • Prev by Date: Re: How to close finder window
  • Next by Date: Re: Cocoa bindings
  • Previous by thread: Re: How to close finder window
  • Next by thread: Re: How to close finder window
  • Index(es):
    • Date
    • Thread