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

[MacPerl] &MacPerl'GetFileInfo() and directory switching




This is my first perl script that is
more than half a dozen lines long, and I
am stuck!

Basically I have a script which
recursively looks through a directory
and displays the Mac File Creator using
the line below , which will then go off
and put an extention on the end
corresponding to the file eg .jpg,
.tiff. etc

($creator, $type) =
&MacPerl'GetFileInfo($fname);

My problem is that if I choose a
recursive directory that the script does
not start in, the File Info and Creator
turn up blank, but it still shows the
filename and directory field.



Any Help would be appreciated.


Thanks

John Watson





#!perl

require "GUSI.ph" ;
require "StandardFile.pl";
if ($#ARGV < 0) { 
   die "No input, no output" 
       unless $file =
&StandardFile'GetFolder("Which folder to
start from?");
   $ARGV[0] = $file;
}
#print "\n\nStartdirname: ",$ARGV[0],"
###\n";
$dirname = $ARGV[0];  
&listDirectory($dirname) ;             
exit 0;

sub listDirectory {
        local($dirname) = @_ ;
								#print "\n\n## Subdirname:
",$dirname," ##\n";
								local(@putval) =
(".mud",".tif",".eps",".jpg");
								local(@crtype) = ( "MuAd",
"TIFF", "EPSF", "JPEG");
							 local(@fnames,@subDirs) ;
       
local($fname,$pathname,$size,$creator,$t
ype,$pname) ;
        if ($dirname !~ /:$/) {
                $dirname =~ s/$/:/;
                }
 opendir(DIR,$dirname) ;
       
        @fnames = readdir(DIR) ;       
        closedir(DIR);

        foreach $fname (@fnames) {      
            ($creator, $type) =
&MacPerl'GetFileInfo($fname);   
													print "Subdirname:
[$dirname] Filename: [$fname] Type:
[$type] Creator: [$creator]";
													$tot = @crtype;
													for ($x=0; $x < $tot;
$x++){
																			if ($ftype eq
$crtype[$x]) {
																									print " ### Ren
to ",$fname.$putval[$x];
																									#rename
$oldfiles, ($oldfiles.$mud);	
																			}
 												}
												print "\n";
												$pathname = $dirname.$fname
;
            if (-d $pathname) {         
                      
                       
&listDirectory($pathname);
            }

        }

}


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