Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'An AppleScript to quickly show or hide hidden files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to quickly show or hide hidden files
Authored by: Derby on Dec 27, '09 07:06:41AM

Hi,
if you want to do that with perl...so here it is a simple script:


#!/usr/bin/perl -w

use strict;
use Getopt::Long;

my ($var,$help,$fal,$tru);
GetOptions(
"false|f=s" => \$fal,
"ture|t=s" => \$tru,
"help|?" => \$help,
);

usage() if($help);
if($fal){
$fal="FALSE";
print `defaults write com.apple.finder AppleShowAllFiles $fal`;
print `killall Finder`;
print "verbose FALSE\n";
exit 1;
}

if($tru){
$tru="TRUE";
print `defaults write com.apple.finder AppleShowAllFiles $tru`;
print `killall Finder`;
print "verbose TRUE\n";
exit 2;
}

#--- M A I N ----------------------------------------------------------------------------
$fal='FASLE';
$tru='TRUE';
$var=`defaults read com.apple.finder AppleShowAllFiles`;
chomp($var);
print "var ist nun: $var\n";
if($var =~ /^T/){
print "var ist: TRUE\n";
print `defaults write com.apple.finder AppleShowAllFiles $fal`;
print `killall Finder`;
}
if($var =~ /^F/){
print "var ist: FALSE\n";
print `defaults write com.apple.finder AppleShowAllFiles $tru`;
print `killall Finder`;
}

print "Can't change variable AppleShowAllFiles\n";
exit 3;
#========================================================

sub usage{
print "Syntax:\n";
print "\t$0 [-f FASLE] [-t TRUE] [-?] [-v]\n";
print "Description:\n";
print "\tThis program changes the variable AppleShowAllFiles to show hidden files in Finder.\n";
print "Flags:\n";
print "\t\t-f FALSE Force the variable to FALSE\n";
print "\t\t-t TRUE Force the variable to TRUE\n";
print "\t\t-? Print this page\n";
print "\t\t--help see -?\n";
print "Examples:\n";
print "1.\n";
print "\t$0\n";
print "2.\n";
print "To force the variable AppleShowAllFiles to be TRUE:\n";
print "\t$0 -t\n";
exit;
}



[ Reply to This | # ]