opening a file in bbedit.

nothing confusing, right?
plain and simple?

i want a script that will open 1 or more files on my hdd (which will become a template .htm and also a .css file in the future). i’m new to this whole thing and have decided to use the record function to do it.

anyways, i’ve run the “record” option and had 'script watch me open a file on my hdd
when i was finished, i clicked “stop”. 'script filled in all of my lovely information, including “open window list”

i clicked check syntax and closed bbedit. after i did that, i ran the script and i got a message saying:

“bbedit got an error: Can’t get {file “hdd name:Users:username:filefolder:filefolder:file”}”

applescript wrote the 'script itself. why isn’t it working?
why didn’t that work?

-mathew

I tried the same thing here in BBEdit and it worked. So maybe we did something a bit different. Here’s what I did…

  1. I launched BBEdit and created a new text document named 12345
  2. Saved it to my desktop
  3. Closed the new document and opened the Script Editor
  4. Hit the record button
  5. Went to the Dock and clicked BBEdit’s icon
  6. Went to the File Menu to Open and selected file 12345
  7. Went back to the Script Editor and hit Stop

Here’s the script it recorded

tell application "BBEdit"
	activate
	open {file "MyDrive:Users:MyName:Desktop:12345"} with LF translation
end tell

It sounds like you didn’t have a document for BBEdit to open.

BBEdit is recordable but the Finder is not, so any actions like double clicking a file will not get recorded.

here’s the steps i took:

open script editor.
click record.
click bbedit in the dock.
click file/open.
navigate through the sheet that comes down to the file i wanted (in this case, style.css).
select the script editor and click stop.
close bbedit.
run script.
“BBEdit got an error: Can’t get {file:etc.}”

i think i tried the same thing that you did. could it be that the file is buried too deep on my hdd? if so, i think that’s pretty silly.

any help others can give me is appreciated.

/edit
is it because i have an extension on the file i want to open? hmm… got to get around that. anyone know how?
/edit

thanks,
-mathew h.

Can you post the code that was generated in the recorded script? Have you tried the record feature directly from BBEdit’s script menu?

edited, of course, to hide the path to the file.

tell application “BBEdit”
activate
open {file “hddname:Users:ownername:subfolder:subfolder:style.css”} with LF translation
end tell

um, no, i haven’t tried bbedit’s record feature.
…i didn’t know there was one. ugh.

thanks,
-mathew h.

Shoot, the only thing I can think of is that maybe the permissions of the folder you are asking for are set wrong. Just for fun, try saving a BBEdit file to your desktop, then try recording the script to open the file on your desktop to see if everything works. If it doesn’t, then something is definately wrong.

I tested the code with BBEdit 6.5.3/OS X 10.2.6 on a couple of local files, including a file with a css extension, and it worked fine, even when the files were buried several folders deep. You might want to check the BBEdit FAQ to see if it’s a bug with your particular version of BBEdit/Mac OS.