Re: Starting directory for 'choose file' [was: Newbie blues (was Remove spaces)]
Re: Starting directory for 'choose file' [was: Newbie blues (was Remove spaces)]
- Subject: Re: Starting directory for 'choose file' [was: Newbie blues (was Remove spaces)]
- From: Richard Morton <email@hidden>
- Date: Mon, 7 Jul 2003 16:39:19 +1000
On Monday, July 7, 2003, at 11:15 AM, webguide wrote:
G'day all,
G'day Kimbo,
In a 'choose file' on OSX is there a way to specify a starting
directory to
look for the file?
Just happened to be looking at this myself, as it happens.
According to posts from Michelle Steiner & julifos, I can confirm the
following:
Michelle posted this, which works for me:
tell application "Finder"
set MyHomeFolder to home as string
end tell
choose file name default name MyHomeFolder & "Documents:"
The above will select the current user's Documents folder using
"Untitled" as the default file name.
To set a recommended file name, you can use this:
tell application "Finder"
set MyHomeFolder to home as string
end tell
choose file name default name MyHomeFolder & "Documents:My File"
But only for 'choose file name'.
julifos posted this:
Every applet choosing a folder should generate an entry in a plist file
auto-generated, determining the last choosen path. So, the next time
you run
your app, it will map to such folder.
I think you can alter such preference:
##########################################
set yourApp to quoted form of "chooseFolder"
set defaultFolder to quoted form of
"file://localhost/Users/x/Documents/"
do shell script "defaults write " & yourApp &
" 'AppleNavServices:ChooseFolder:0:Path'" & defaultFolder
choose folder
##########################################
For a "choose file name" you may write the defaults for
"AppleNavServices:PutFile:0:Path" (untested, but may work)
I just tried it and found that it only works for AS applets and that
the applet must be run first, i.e. that the plist file can be
*changed*, but not *generated* in this way. In other words, the app
has to be run first.
It would be possible to generate the whole file (using read/write
commands) I guess, but I don't know what the other two entries mean:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AppleNavServices:ChooseFolder:0:Path</key>
<string>file://localhost/Users/luser/Documents/</string>
<key>AppleNavServices:ChooseFolder:0:Position</key>
<data>
ARoBMw==
</data>
<key>AppleNavServices:ChooseFolder:0:Size</key>
<data>
AAAAAAFeAfM=
</data>
</dict>
</plist>
And even this won't do you any good if it's not an applet. There may
be other ways, but I haven't found them yet.
Cheers,
Chew Zee
-- Identify your last port of call, Space Wanderer...
_______________________________________________
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.