Re: Creeping-featuritis
Re: Creeping-featuritis
- Subject: Re: Creeping-featuritis
- From: "Wallace, William" <email@hidden>
- Date: Tue, 17 Apr 2007 12:33:30 -0500
- Thread-topic: Creeping-featuritis
Title: Re: Creeping-featuritis
I had a different approach to this problem. I did not use a droplet but instead chose to make a selection in a Finder window and then run my script from the script menu. The path was always formatted in Macintosh format in my innitial approach. Later I realized that there we times when I wanted the path in unix format. I considered just writing a second script for that, and I also considered formatting the path both ways in the same script and putting them both on the clipboard (then I would just delete the format I didn’t want). But looking at your implementation, I decided to change my approach to something similar to yours:
--available modes are Mac, Unix, or Both.
property thePathMode : "Mac"
set theFileList to {}
set thePathString to ""
tell application "Finder" to set theFileList to selection
repeat with i from 1 to count of theFileList
set theMacPath to ((item i of theFileList) as text) & return
set thePosixPath to (POSIX path of (item i of theFileList as alias)) & return
if thePathMode is "Mac" then
set thePathString to thePathString & theMacPath
else if thePathMode is "Unix" then
set thePathString to thePathString & thePosixPath
else
set thePathString to thePathString & theMacPath & thePosixPath
end if
end repeat
if thePathString = "" then
set the thePathMode to button returned of (display dialog "You do not have an item selected in the Finder. Choose a path format and select an item (or items) in the Finder and run this script again." with title "Path format preferences" buttons {"Mac", "Unix", "Both"} default button "Mac")
else
tell application "Finder" to set the clipboard to thePathString
end if
Now my script has a prefences panel. You access it by running the script with nothing selected in the Finder. Thanks for the inspiration. ;-}
--
St!ff M!ttens
From: Michelle Steiner <email@hidden>
Reply-To: Applescript Users <email@hidden>
Date: Tue, 17 Apr 2007 09:03:29 -0700
To: Applescript Users <email@hidden>
Subject: Creeping-featuritis
The goal was to get the pathname of a file or folder onto the clipboard.
The solution was simple:
on open {dropped_item}
tell application "Finder" to set the clipboard to the dropped_item as text
end open
The solution, after creeping-featuritis:
property Default_button : "Macintosh format"
on open {dropped_item}
set the display_format to button returned of (display dialog "Which format do you want the file path in?" with title "Choose display format" buttons {"Cancel", "Unix format", "Macintosh format"} default button Default_button)
set the Default_button to the display_format
if the display_format is "Unix format" then set the dropped_item to the POSIX path of the dropped_item
tell application "Finder" to set the clipboard to the dropped_item as text
end open
--
"I'll do the best I can do because that's the best I can do!"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden