Re: Find all PowerPC Applications in Applications folder
Re: Find all PowerPC Applications in Applications folder
- Subject: Re: Find all PowerPC Applications in Applications folder
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 06 Apr 2011 21:10:15 -0400
On Sun, Apr 3, 2011 at 5:32 PM, Christopher Stone
<email@hidden> wrote:
> Given that how would you grab the whole record for each ppc app? I'd think you could easily find on the whitespace-App-Name-:, discover the ppc kind, and wrap up with the location.
It depends on what you want to do with the whole record once you've
grabbed it. I mean, it's easy to get an array of hashes in Perl:
#!/usr/bin/perl
local $/ = '';
my @apps = ();
open my $pipe, "system_profiler SPApplicationsDataType|";
my $skip = <$pipe>; # skip "Applications: "
while (<$pipe>) {
s/^\s*//;
s/:.*$//ms;
my $app = { Name => $_ };
my $data = <$pipe>;
$app->{$1} = $2 while $data =~ /^\s*([^:]*):\s*(.*)$/gm;
push @apps, $app;
}
which you can then do Perly things with, like this to duplicate the
output of the previous script:
print join("\n", map { $_->{Location} } grep { $_->{Kind} eq 'PowerPC'
} @apps), "\n";
As a side note, the application name (the one that appears on a line
by itself between two blank lines) is not necessarily unique; you can
have two instances of the same application in different Locations.
That's why I build an array instead of a hash at the top level.
--
Mark J. Reed <email@hidden>
_______________________________________________
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