MacPerl, OS 9, move file to Trash

X

Xiong Changnian

My little utility-in-the-making will scan a folder full of backups and
move the oldest ones to the Trash. So I'd like to hope.

I'm doing fine right up to the point where I wish to make the actual
move. That is, I've identified the files I wish to Trash -- I have the
full path in the form preferred under Mac OS 9.

So, what next? The usual Perl resources are no help, of course; this
issue is all about the Mac way of doing things. I dug through the
specialized-for-Mac modules included in the MacPerl distro; none seem to
fit the bill -- I can't imagine why, I think I must be overlooking
something. I'm pretty much a Perl novice.

It seems risky to go shoving files around directly; that's not the Mac
way. Hey, what about AppleScript? And indeed, I've got a little gimmick
working, sort of:

my $script;
$script = <<END;
tell application "Finder"
move file ("$deadfile") to trash
end tell
END

MacPerl::DoAppleScript($script) #do the trash script
or die ("AppleScript failed: $! \n");

This really does work -- very slowly and only once. If I call it twice
in a row (with two different path/filenames for $deadfile), MacPerl
stalls, stalls, stalls and if I start randomly clicking the mouse, I
hear the little "ding" of a file hitting the Trash. Then, nothing, no
matter what I do -- until I force-quit MacPerl. Then I get the second
"ding". Sure enough, both files are Trashed. I never die.

It seems that MacPerl is hogging time. It tells the Finder and the
Finder gets the command; but then MacPerl doesn't give it any time in
which to act. Not clear why clicking around sometimes helps; perhaps
it's just enough to burp a handler and the Finder gets a little time on
the way out -- something like that.

But basically -- I think -- Finder is waiting to be given time, while
MacPerl is waiting for a return from MacPerl::DoAppleScript(). Does that
seem right?

For the record, it's Mac OS 9.2.2, MacPerl 5.6.1r2 and yes, I have other
Perl scripts working fine.

* * *

So, let's speak frankly. I expect a number of responses and I'd like to
pre-reply to some of them.

* I realize this looks a little off-topic for this newsgroup and I'm
sorry about that. I don't have the first idea where to go for help; I
see no "*.macperl" NG.

* I did RTFM. I R all TFM I could lay my hands on. I've searched high
and wide on the infobahn. A pointer to a resource that actually contains
a solution to my problem is probably *better* than the solution itself,
yes, thank you. I'll look there first, next time.

* It's probably better not to adapt solutions intended for other
platforms, such as direct deletion. We Mac folks expect files to be
moved to the Trash, not deleted instanter. Sometimes we poke around in
the Trash before emptying it.

* It's my Mac. Yes, it is old and wheezy and small children throw stones
at my car when I drive to the corner store. Sorry, but all solutions
that include buying a new Mac and/or installing OS X are out, for today.
Same for those that require me to buy a real computer.

Many thanks await my White Knight.
 
X

Xiong Changnian

Sherm Pendley said:
Just renaming them should work.

It might. I'd really rather *move* files to Trash, rather that jigger
the system. Mac plays nice if you play nice with Mac.

Yes, I read that post and its reply, too. It's about renaming to
faux-move. I've also read 2 or 3 discussions in other places reporting
problems with this approach.

I'd really prefer to get AppleScript calls working. Who knows, I may be
able to do something else with them.
lists.perl.org

It's lists.cpan.org now. I've been subscribed to the original MacPerl
mailing list since 2004; it's dead, nobody ever posts, not even spam.

Almost all forum discussion -- no matter where it's held -- revolves
around MacPerl for OS X. This is a whole different animal, of course,
since OS X is just a wrapper around a unix-ish box.

I suppose I should subcribe to a half-dozen MacPerl OS X forums and
troll for solutions there. I'm still hoping somebody in this group has
some experience with OS 9.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,262
Messages
2,571,058
Members
48,769
Latest member
Clifft

Latest Threads

Top