• 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 do some AppleScript inside a Perl program to label duplicates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to do some AppleScript inside a Perl program to label duplicates


  • Subject: Re: How to do some AppleScript inside a Perl program to label duplicates
  • From: Adam Wuellner <email@hidden>
  • Date: Fri, 16 Sep 2005 10:52:34 -0500

On 9/16/05, Gary (Lists) <email@hidden> wrote:
> "pete boardman" wrote:
>
> > [...] that probably means inserting some
> > AppleScript into the Perl program. I can do the AppleScript bit:
> >
> > --
> > tell app "Finder" to set the label index of f to 6
> > --
> >
> > and I know where in the Perl file is the loop that prints out the
> > pathnames of the duplicate files:
> >
> > --
> >  for (@{$pair{$i}}) {
> >            print $$_,"\n";
> >    }
> > --
> >
> > All I need to know now is how to combine them: I want to set the
> > label of the file $$_ (I think - Perl has more punctuation than I can
> > cope with.)
>
> Peter,
>
> Strictly responding to your question, you will likely want to explore two
> Perl modules, "Mac::Glue" and "Mac::AppleScript", which are both available
> from CPAN (links below.) [...]

Gary, as usual, has excellent suggestions, but I'd like to add
one very easy solution[1] to your choices.  It won't win any
awards from Perl programmers, but it really couldn't be more
straightforward.  Perl has a number of ways to 'shell out' and
execute command line, um, commands in the middle of doing its
other things.

> >  for (@{$pair{$i}}) {
> >            print $$_,"\n";
> >    }

If you still want the filenames printed, as it seems you do, then
you'd simply add a line to the block inside this for loop that
executes the command 'osascript -e "tell application....".
Here's one way to do it:

for (@{$pair{$i}}) {
    print $$_,"\n";
    system("osascript -e 'tell application \"Finder\" to set the label
index of (POSIX file \"$$_\") to 6'");
}

[1] Well, this isn't a solution, yet.  I tried testing that
osascript command both in a similar perl context as well as in
Terminal.  In both places, I get:

  29:nnn: execution error: Stack overflow. (-2706)

So if you can figure out a way to get your AppleScript to work
from osascript, then you can use this approach.  I'm not sure why
it doesn't work as written.

Sorry this fell short, but maybe it was interesting anyway. :)

Adam
 _______________________________________________
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

  • Follow-Ups:
    • Re: How to do some AppleScript inside a Perl program to label duplicates
      • From: pete boardman <email@hidden>
References: 
 >How to do some AppleScript inside a Perl program to label duplicates (From: pete boardman <email@hidden>)
 >Re: How to do some AppleScript inside a Perl program to label duplicates (From: "Gary (Lists)" <email@hidden>)

  • Prev by Date: Re: """
  • Next by Date: Re: """
  • Previous by thread: Re: How to do some AppleScript inside a Perl program to label duplicates
  • Next by thread: Re: How to do some AppleScript inside a Perl program to label duplicates
  • Index(es):
    • Date
    • Thread