Re: [MacPerl] beginner file type access thingy
[email protected] Sat, 10 Mar 2001 07:26:26 +0900
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <v04011703b6cef3cb1e5c@[211.132.153.164]> |
"Dan Wolchonok" <[email protected]> wrote >I am wondering if I could write a cgi macperl script that can change the >file creator/type. this script is from 'MacPerl: Power and Ease' by V. Brown & C. Nandor ===script1==== #!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('ttxt', 'TEXT', @files); ===script1==== Though it's not clear what you want to do with the server - is it a Mac? Do you have acess to it physycally? If so save this script as a droplet (make sure you don't copy the '===script====' parts with the source text) and just drag any folders containing files you want to alter onto it ===script2==== #! perl -w use strict; use diagnostics-verbose; use Mac::Files; my ($dir,%info,@files,$i,$file,); # loop through the dropped files/directories for ($i = 0; $i <= $#ARGV; $i++) { # check if we have a directory if (-d $ARGV[$i]) { $dir = $ARGV[$i]; chdir($dir); # store the directory name opendir(DIR, $ARGV[$i])or die "Can\'t open $ARGV[$i]\n"; # open the directory foreach $file (readdir(DIR)) { if (-f $file && MacPerl::GetFileInfo($file) eq 'TEXT') { MacPerl::SetFileInfo('ttxt', 'TEXT', $file); } } } close (DIR); } ===script2====