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

Re: [MacPerl] How to change a file's type & creator?



Shai Spharim, <shai@kswaves.com> wrote:

> I have utility that reads one file, sorts and massages and writes 
> every thing to a new file. I would like the new file to have the same type 
and
> creator as the old one.

I smell a FAQ!

You can do this using the MacPerl package, which includes the command:

MacPerl::SetFileInfo(CREATOR, TYPE, FILE)

Here's an example, lovingly borrowed (okay, crudely stolen!) from MPPE 
(page 174):

#!perl -w
my($dir, $file, @files);
$dir = 'HD:Desktop Folder:Text Files';

chdir($dir);
opendir(D, $dir) or die($!);

foreach $file (readdir(D)) {
    if (-f $file &&
        MacPerl::GetFileInfo($file) eq 'TEXT') {
    push (@files, $file);
    }
}
MacPerl::SetFileInfo('R*ch', 'TEXT, @files);

__END__

Of course this example doesn't SOLVE your problem, that's still up to you.

Brian McNett, Webmaster
*************************************************************
Mycoinfo. The world's first mycology e-journal.
http://www.mycoinfo.com/
*************************************************************


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org