Hi folks.
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"
tell application "BBEdit 9.6"
open myF as alias
end tell
It says can't get the file. I know it's there. I've tried how to
change the syntax on the open and I just can't get it. Any ideas?
Cheers
--
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 bbe...@googlegroups.com
To unsubscribe from this group, send email to
bbedit+un...@googlegroups.com
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 "sup...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>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"
>
>tell application "BBEdit 9.6"
> open myF as alias
>end tell
>
>It says can't get the file. I know it's there. I've tried how to
>change the syntax on the open and I just can't get it. Any ideas?
The path format doesn't match; assuming you want to use Unix paths:
====
set myF to POSIX file "/Users/pwoolsey/Desktop/foo.txt"
tell application "BBEdit"
open myF
end tell
====
Regards,
Patrick Woolsey
==
Bare Bones Software, Inc. <http://www.barebones.com>
P.O. Box 1048, Bedford, MA 01730-1048
That resulted in a "doesn't understand the open message". If I want to avoid the POSIX syntax, do I use colons? Still didn't work.
Tried colons, didn't work.
Cheers
On 2011-06-22, at 3:12 PM, Lorin Rivers wrote:
> Glen,
>
> In all my scripts that open files, I use this structure instead:
> open {file "infernal:private:etc:apache2:httpd.conf"}
>
> Which is what AppleScript emits if you record BBEdit opening a file.
>
> HTH!
On 2011-06-22, at 3:58 PM, Doug McNutt wrote:
> I'm biased but the sooner one gets out of Applescript the better UNIX works.
>
> Install the bbedit tool from Bare bones
>
> do shell script "bbedit " & quoted form of "/Library/WebServer/Documents/alpha/bravo/items.lasso"
--
As an option, I'm trying to use AppleScript syntax for a single replace and save. This is what I have for the replace, and she's not compiling:
replace "\x0B" using "\r" searching in selection of text window 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
Any ideas? That is a gremlin inserted by our lovely FileMaker.
Cheers
On 2011-06-22, at 4:04 PM, Robert Huttinger wrote:
Sent from my iPhone
>That resulted in a "doesn't understand the open message".
Should work; what was the exact text of your script? (and, did you replace
my example path with a valid path? :)
>If I want to avoid the POSIX syntax, do I use colons?
Yes; in that case you should write the path in traditional AppleScript
fashion and use 'alias', like this:
===
set myF to alias "Hard Drive:Users:pwoolsey:Desktop:foo.txt"
...
OK, got it to work:
open myF as alias
Any clarification on the POSIX notation?
Thanks Patrick!
On 2011-06-22, at 3:25 PM, Patrick Woolsey wrote:
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
Unfortunately that didn't work either on 777.
> Hi folks.
>
> 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"
>
> tell application "BBEdit 9.6"
> open myF as alias
> end tell
>
> It says can't get the file. I know it's there. I've tried how to
> change the syntax on the open and I just can't get it. Any ideas?
>
> Cheers
Glen,
In all my scripts that open files, I use this structure instead:
open {file "infernal:private:etc:apache2:httpd.conf"}
Which is what AppleScript emits if you record BBEdit opening a file.
HTH!
--
Lorin Rivers
Mosasaur: Killer Technical Marketing <http://www.mosasaur.com>
<mailto:lri...@mosasaur.com>
512/203.3198 (m)
open myF as alias
Any clarification on the POSIX notation?
Thanks Patrick!
On 2011-06-22, at 3:25 PM, Patrick Woolsey wrote:
I'm biased but the sooner one gets out of Applescript the better UNIX works.
Install the bbedit tool from Bare bones
do shell script "bbedit " & quoted form of "/Library/WebServer/Documents/alpha/bravo/items.lasso"
--
--> A fair tax is one that you pay but I don't <--
Cheers
How can I then launch a Text Factory on that file? I can't seem to find anything in the dictionary.
choose file
Then navigate to and "open" the file, and copy the result. :-)
-boo
At 11:08 p -0400 06/22/2011, BeeRich didst inscribe upon an electronic papyrus:
______________________________________________________________________
That can be handy, but it's also a bit limiting due to its restriction to files. Folders are not allowed.
More versatile is:
choose file with multiple selections allowed
or
choose folder with multiple selections allowed
Unless you really do want only one specific item.
I never use these unless I require user interaction in a script. The scripts I posted yesterday do the job for me, and just in case I have the following script available via a few keystrokes from Typinator:
tell application "Finder"
set sel to selection as alias list
end tell
In general I'd much rather navigate around the Finder itself rather than through a dialog.
--
Best Regards,
Chris
At 08:48 a -0400 06/23/2011, BeeRich didst inscribe upon an electronic papyrus: