• 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: "Gary (Lists)" <email@hidden>
  • Date: Fri, 16 Sep 2005 11:03:29 -0400

"pete boardman" wrote:

> Anyone know how to run a bit of AppleScript from inside a Perl
> script? I found a neat Perl script which finds duplicate files. It
> prints each set of duplicate files out on the terminal like this:
>
> --
>
> /Users/pete/projects/a/doc1.doc
> /Users/pete/projects/a/backup1/doc1.doc
> /Users/pete/projects/a/backup2/doc1.doc
>
> --
>
> plus information about their size. What I'd like to do is label these
> files in the Finder. But 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.)

However, I could also suggest turning the question and looking at the
(perhaps more modular) approach of simply wrapping your Perl script around a
very short AppleScript which would pass off the files to the Perl, then do
whatever action you want (Finder labeling, you said.)

I suggest this because I've just gone through the same procedure, where I
wanted to use my installed "Markdown" as a Perl script, as a TextWrangler
Unix Filter and as an AppleScript droplet.

That's when I researched the Perl modules mentioned, and where I also came
to the conclusion that I should stick to what I know (a little about
AppleScript). [Although the Mac::AppleScript looks closest to just
'embedding' AppleScript statements, as opposed to constructing raw
AppleEvents.]


As for efficiency if your batches are large (you will be looping on _many_
files), then perhaps injecting the AS into the Perl script is more efficient
and worth the time to learn/implement the Perl mods.  That's your call. My
task was not very loopy, if you will.

HTH  :-/

Mac::Glue
http://search.cpan.org/~cnandor/Mac-Glue-1.25/Glue.pm

Mac::AppleScript
http://search.cpan.org/dist/Mac-AppleScript/

--
Gary

 _______________________________________________
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: Steve Hayman <email@hidden>
    • Re: How to do some AppleScript inside a Perl program to label duplicates
      • From: Adam Wuellner <email@hidden>
    • 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>)

  • Prev by Date: Can't Get Mailbox of Selected Message in Mail.app (10.4)
  • Next by Date: Re: Properties within Properties - Scripting Address book
  • 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