Re: Rename Droplet Works in OS 9 But Not X
Re: Rename Droplet Works in OS 9 But Not X
- Subject: Re: Rename Droplet Works in OS 9 But Not X
- From: Ben Waldie <email@hidden>
- Date: Thu, 3 Jul 2003 14:41:28 -0400
Micahel,
On Thursday, July 3, 2003, at 01:41 PM, Alatorre, Michael wrote:
Here is a simple rename droplet that works in OS 9:
on open theFile
tell application "Finder"
select theFile
set name of selection to "PEAC-SMG.xls"
end tell
end open
But, if I use the same code in OS X, I get this error:
Can't set name of selection of application "Finder" to "PEAC-SMG.xls".
If it's related to differences in the Finder, does anyone have a
suggestion
on how to accomplish this in X?
The problem here is that OS X is returning the selection as a list.
Also, when you use the "open" handler, the items dropped on the script
are also passed as a list. So, you need to be a little more specific.
There are a couple of ways to do this...
on open theFile
tell application "Finder"
select theFile
set theSelection to selection
set name of (item 1 of theSelection) to "PEAC-SMG.xls"
end tell
end open
OR
on open theFile
set theFile to item 1 of theFile
tell application "Finder"
select theFile
set name of theFile to "PEAC-SMG.xls"
end tell
end open
- Ben
Benjamin S. Waldie
Automated Workflows, LLC
=============================================
AppleScript and Workflow Automation
Consulting - <
http://www.automatedworkflows.com>
AppleScript Info - <
http://www.applescriptguru.com>
AppleScript Training - <
http://www.applescripttraining.com>
=============================================
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.