On Jun 22, 2011, at 14:04, Rich F wrote:
> For the life of me I can't find a way of opening a file in a subdirectory in
> my webserver directory...
> set myF to file "/Library/WebServer/Documents/alpha/bravo/items.lasso"
______________________________________________________________________
Hey Rich,
It's been mentioned that you're using the wrong syntax there to reference a
file 'as alias'.
Note that BBEdit will deal with a posix path without conversion to a posix file
or alias:
----------------------------------------------------------------------
set posixFileRef to "/Users/chris/test_directory/test.txt"
tell application "BBEdit"
open posixFileRef
end tell
----------------------------------------------------------------------
In the Finder I run this script with FastScripts using 'Control-P' to put
alias-formatted references of the selected items on the clipboard:
----------------------------------------------------------------------
# Author: ccs
# Created: 12-29-2010 : 18:48:00
# Modified: 01-05-2011 : 02:15:00
# Application: Finder
# Purpose: Copy Alias reference of selected items to the Clipboard.
# Dependencies: none
----------------------------------------------------------------------
tell application "Finder"
try
set sel to selection as alias list
if length of sel > 0 then
set beginning of sel to ""
set end of sel to ""
set AppleScript's text item delimiters to {"\"" & return & "alias " &
"\""}
set sel to sel as string
set sel to paragraphs 2 thru -2 of sel
set AppleScript's text item delimiters to return
set sel to sel as string
set the clipboard to sel
end if
on error errMsg number errNum
beep
display dialog "Error: " & errMsg & return & "Error Number: " & errNum
end try
end tell
----------------------------------------------------------------------
I find that automating this task leads to fewer mistakes and "Doh!' moments. :)
Here's a similar script for Posix paths:
----------------------------------------------------------------------
# Author: ccs
# Created: 2010-10-06 : 06:43
# Modified: 2011-06-22 : 17:00
# Application: Finder
# Purpose: Get posix path of selected items and copy to clipboard
# Dependencies: none
----------------------------------------------------------------------
tell application "Finder"
try
if (count of windows) > 0 then
set sel to selection as alias list
if length of sel > 0 then
repeat with ndx in sel
set ndx's contents to "\"" & (POSIX path of ndx) & "\""
end repeat
set AppleScript's text item delimiters to linefeed
set sel to sel as string
set the clipboard to sel
end if
end if
on error errMsg number errNum
beep
display dialog "Error: " & errMsg & return & "Error Number: " & errNum
end try
end tell
----------------------------------------------------------------------
--
Best Regards,
Chris
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>