On Jan 23, 2017, at 09:38, Greg Raven <[email protected] 
<mailto:[email protected]>> wrote:
> This is what I came up with:


Hey Greg,

That'll work fine.

Here's what I'd do:

----------------------------------------------------------------------
# USER SETTINGS:
----------------------------------------------------------------------

# Relative-Path (tilde or $HOME-based path) if possible.
set projectPath to "~/Documents/BBEdit Projects/INFO-PROJECT.bbprojectd"

set appList to items 1 thru -2 of {¬
   "GitHub Desktop", ¬
   "TextEdit", ¬
   "Transmit", ¬
   ""}

-- Written this way for easy additions, removals, and sorting.

----------------------------------------------------------------------

tell application "System Events" to set projectPath to POSIX path of disk item 
projectPath

repeat with theApp in appList
   tell application theApp
      if it is not running then run
   end tell
end repeat

tell application "BBEdit"
   if it is not running then -- This code works-around an “activate” bug in 
some versions of macOS.
      run
      delay 1
   end if
   activate
   open projectPath
end tell

----------------------------------------------------------------------

Rule-of-the-thumb – never use full paths if a relative path will work.

I generally use relative-aliases, but most people don't understand these as 
well as tilde-based paths (as I've used above).

An example of same:

set projectAlias to alias ((path to documents folder as text) & "BBEdit 
Projects:INFO-PROJECT.bbprojectd:")

** “Relative-Alias” is a term I coined years ago and is not official Apple 
nomenclature.

Relative paths (and relative aliases) are portable.  Hard-coded full-paths are 
very often NOT portable.

System Events understands tilde-based paths (as seen in the script), but don't 
use any kind of POSIX Path in the Finder.  (While there are instances that work 
there are many more that don't, so it's better to stick with HFS paths and 
aliases when working in the Finder.)

--
Take Care,
Chris


-- 
This is the BBEdit Talk public discussion group. 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>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to