save BBEdit doc within specific folder

hi
very new to Applescript, I need to fine tune the one below which creates a set of new folders (in a location I am prompted to choose), and open a BBEdit new document. I would need it to:
1/ check if BBEdit.apps is already open, and if not open it
2/ create a new BBEdit document
3/ save it to a specific folder (one just created by the script) eg. the Brief folder

set theFolder to choose folder with prompt “Create/Choose Client Project folder”
tell application “Finder”
set briefFolder to make new folder at theFolder with properties {name:“Brief”}
end tell
tell application “BBEdit”
make new document at beginning with properties {name:“$.todo”}
end tell

your expertise would be great!
cheers,

AppleScript: 2.2
Browser: Safari 523.10.6
Operating System: Mac OS X (10.5)

Hi Pascal,

try this:


set theFolder to choose folder with prompt "Create/Choose Client Project folder"
try
	set briefFolder to ((theFolder as text) & "Brief") as alias
on error
	tell application "Finder" to set briefFolder to make new folder at theFolder with properties {name:"Brief"}
end try
tell application "BBEdit"
	set briefDoc to make new document at beginning with properties {name:"$.todo"}
	save briefDoc to ((briefFolder as text) & "$.todo")
end tell

thanks Stefan! it works nicely :slight_smile: