Eu tentei alguns casos e parece que funciona conforme necessário:
Script de shell, usr/bin/perl
, passagem de entrada as arguments
.
useFile::Find;find({wanted=>\&find_files,no_chdir=>1},@ARGV);subfind_files{if(-f$_){($file)=$_=~/.*\/(.*)$/;push(@all_files,$_)if($filene".DS_Store");
}
else
{
push (@all_folders, $_);
}
}
sub osascript($) { system 'osascript', map { ('-e', $_) } split(/\r/, $_[0]); }
foreach(@all_files)
{
@paths = split(/\//, $_);
for $i (0..$#paths-1)
{
if ($i == 0)
{
$x = "$paths[$i]";
}
else
{
$x = "$last[$i-1]/$paths[$i]";
}
push(@last, $x);
$temp{$x} ++;
}
@last = ();
}
@not_gray_folders = keys %temp;
foreach(@all_folders)
{
$folder = $_; $flag = 0;
foreach(@not_gray_folders)
{
if ($folder eq $_)
{
$flag = 1;
}
}
if (!$flag)
{
$label = 7;
}
else
{
$label = 0;
}
&osascript ("tell application \"Finder\" to set label index of alias POSIX file \"$folder\" to $label");
}