[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Setting the "label" on folders



At 21.27 -0400 1998.10.06, Fred Giorgi wrote:
>Does anyone know how to set the label field on folders with perl?
>I would like to set the label field to some color based on how many files
>are in the folder.
>I would like to drop a folder on a prel icon and automatically set the
>"label" attribute on all subfolders.
>For example:
>folder is empty - no label
>folder contains 1 to 10 files - orange
>folder contains 10 to 20 files - red
>Any help would be appreciated.

Well, as usual, three ways.  :-)  All examples set the label index of Trash
to the 2, which is the second label in your list of labels.

Method 1:

  MacPerl::DoAppleScript(<<EOS);
  tell application "Finder"
    set label index of item "Trash" to 2
  end tell
  EOS

Method 2:

  #!perl -wl
  use Mac::AppleEvents::Simple qw(:all);
  $obj1 = 'obj {form:name, want:type(cobj), seld:TEXT(@), from:null()}';
  push @params, "Trash";
  $obj2 = "obj {form:prop, want:type(prop), seld:type(labi), from:$obj1}";
  do_event(qw/core setd MACS/, "'----':$obj2, data:2", @params);

Method 3:

I don't know yet.  'label index' is a property of 'item', and right now I
don't do labels in the glue.  Thoughts are welcome.  But by the time the
Glue hits beta, there will be a Third Method here.  :-)

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch