Re: ongoing Senior moments
Re: ongoing Senior moments
- Subject: Re: ongoing Senior moments
- From: Robert Poland <email@hidden>
- Date: Mon, 01 Dec 2014 10:03:13 -0700
> On Dec 1, 2014, at 7:49:AM, Yvan KOENIG <email@hidden> wrote:
>
>
>> Le 01/12/2014 à 14:07, Thomas Fischer <email@hidden> a écrit :
>>
>> Hello,
>>
>> Am 01.12.2014 um 12:53 schrieb Shane Stanley <email@hidden>:
>>
>>> On 1 Dec 2014, at 10:38 pm, Yvan KOENIG <email@hidden> wrote:
>>>
>>>> I'm puzzled.
>>>>
>>>> Must I assume that the french system is more fair than the English one ?
>>>
>>> No; I was using a path to a folder that didn't exist. But I still don't fancy relying on it longer-term. Especially when there's a simple alternative:
>>>
>>> use framework "Foundation"
>>> use scripting additions
>>>
>>> set theFolder to "~/Pictures/APOD ƒ/"
>>> set theFolder to (current application's NSString's stringWithString:theFolder)'s stringByExpandingTildeInPath() as text
>>> set theFile to (choose file default location (POSIX file theFolder) as alias)
>>
>> while I tend to agree on the long-term reliability issue I have to confess: I don’t like ASObjC!
>> In an AppleScript context it sticks out like a sore thumb.
>> I also would be hard pressed to call
>>> set theFolder to (current application’s NSString’s stringWithString:theFolder)'s stringByExpandingTildeInPath() as text
>> a simple alternative to
>> tell application "System Events“ to set theFolder to path of disk item theFolder
>> even disregarding the use clauses.
>>
>> Cheers
>> Thomas
>
> Hello Thomas
>
> I brought this old thread to the surface because Yosemite introduced a change : before it,
>> tell application "System Events“ to set theFolder to path of disk item theFolder
> failed.
> We had to use a bit of trickery :
>
> set theFolder to "" & "~/Pictures/APOD ƒ/"
> set theFolder to my convertTildePathToHfs(theFolder)
> set theFolder to (choose file default location alias theFolder)
>
>
> on convertTildePathToHfs(aPath)
> set pp to POSIX file (do shell script "echo " & quoted form of aPath)
> log pp
> tell application "System Events"
> path of disk item (pp as text)
> end tell
> return result
> end convertTildePathToHfs
>
> or, if we need only one conversion we may use :
>
> set theFolder to "" & "~/Pictures/APOD ƒ/"
> POSIX file (do shell script "echo " & quoted form of theFolder)
> tell application "System Events" to set theFolder to path of disk item (result as text)
> set theFolder to (choose file default location alias theFolder)
>
>
> As far as I know, it's only with Yosemite that the use of echo is not required.
>
> Yvan KOENIG (VALLAURIS, France) lundi 1 décembre 2014 15:49:39
As usual, I’m confused;
What’s wrong with this method?
set theFolder to "" & (path to home folder as text) & "Pictures:APOD ƒ:"
set ThePicture to (choose file default location alias theFolder)
Robert Poland
Fort Collins CO
_______________________________________________
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