Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Open several apps and docs with a double-click UNIX
I work on a project that requires me to open several applications and documents at once, and it's a pain to hunt around for everything or clutter my desktop with aliases. To solve the problem I created a *very* simple script that opens everything I need in one shot. Here's how:
  1. Open any text editor that can create plain text files and create a new document.
  2. For each application you want the script to open, type a line that reads: open /Applications/ApplicationName.app. For some applications, you don't need the .app, and for applications that aren't in your Applications folder, you'll need to enter the appropriate path. One way to figure out the appropriate path is to open a new window in Terminal (in Applications -> Utitlies) and drag the file in question over it. The path will print out automatically, and you can copy this text into the script.
  3. Documents can be trickier because they often have spaces in their names. If they do, add the escape character before each space. For example:
    open /Users/davidtdphil/Desktop/Thesis\ Bibliography.enl
    
  4. Save the document as a plain text file (ASCII) and append .command to the name. For example, myscript.command.
  5. Open a new window in Terminal and type chmod 774 (notice the trailing space!). Don't press return yet. Instead, drag the file you've just saved over the terminal window. Its path will print out automatically. Now you can hit Return. This step makes the file executable for you and others in your group. Everyone else can just read it.
Voila! Your timesaving script is born. Now you can double-click this file, and every item you specified in the script will open. To change the items, you can open the script from within any text editor.

[robg adds: When I have batches of stuff like this to open for certain projects, I tend to just create project folders, each containing aliases of the apps and/or documents that I want to open. I can also use Butler to create groups of items that launch and/or open when activated via a hot key. However, the above is a good example of how to use the Terminal's Finder integration to build a simple launcher script.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,370 views]  

Open several apps and docs with a double-click | 10 comments | Create New Account
Click here to return to the 'Open several apps and docs with a double-click' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open several apps and docs with a double-click
Authored by: fresler on May 17, '04 02:47:35PM

I do something similar in AppleScript. On launch, my script checks to see if I'm currently on the network at work. If i am, it mounts three servers and launches several apps. it is definately a time saver!



[ Reply to This | # ]
Open several apps and docs with a double-click
Authored by: Han Solo on May 17, '04 08:17:17PM

What is the syntax for checking if you are connected to a network — or better, if a particular networked drive is already mounted?



[ Reply to This | # ]
Open several apps and docs with a double-click
Authored by: fresler on May 18, '04 11:24:25AM

I'm not sure about how to test to see if a Network drive is already mounted. I've included my ApplesScript below. The first line is where I test to see if I'm on the network at work. The IP address is one of our servers. So, if i get a response from the ping, I know I'm on the network.

set zippy to do shell script "ping -c 1 192.168.1.93"
if zippy contains "1 packets received" then

tell application "Finder"
try
mount volume "smb://192.168.1.93/root"
mount volume "smb://192.168.1.25/evalnow"
mount volume "smb://192.168.1.181/notes"
end try
end tell

tell application "Mail"
activate
end tell

tell application "Netscape"
activate
end tell

tell application "Safari"
activate
end tell

tell application "iChat"
activate
end tell

tell application "BBEdit"
activate
end tell

end if



[ Reply to This | # ]
Open several apps and docs with a double-click
Authored by: arosen on May 17, '04 07:05:12PM
The problem with that method is that the terminal app is started up and then left open. A cleaner way in my opinion is to create an applescript with the "do shell script" command. For example, all you need in the code is: do shell script "open /Applications/Chess.app"

[ Reply to This | # ]
Open several apps and docs with a double-click
Authored by: pmccann on May 17, '04 11:03:58PM

Don't forget the "open -a" syntax. It's much easier than specifying a path to an application (with or without the ".app" suffix). To open Chess, for example, just use

open -a chess

(yep, the case doesn't matter). Of course if your app isn't hiding in the /Applications directory (or ~/Applications) or a subfolder thereof it won't be found, but for standard apps in standard places this saves some time.



[ Reply to This | # ]
Open several apps and docs with a double-click
Authored by: pecosbill on May 18, '04 12:41:59AM
I don't understand why you don't just make a folder... call it My Heinous project or Daily Open or whatever... then
do script "open /path/to/folder/*"
which will then tell the OS to open anything in that folder. You put aliases of whatever suits you into it (cmd-opt-drag). I presume these need to be supported by the open command which generally means something you can double click in the GUI (not sure about X11).

(BTW, on the Mac, it's an option key. PCs use ALT in garish caps)

---
Pecos Bill

[ Reply to This | # ]

Open several apps and docs with a double-click
Authored by: pecosbill on May 18, '04 12:48:58AM
ooops. make that
do shell script "open /path/to/folder/Daily\ Open/*"

---
Pecos Bill

[ Reply to This | # ]

Open several apps and docs with a double-click
Authored by: donfarrar on May 18, '04 10:07:05AM

I don't get it. Admittedly, as someone who does not use Terminal or write AppleScript code, I still found the hint interesting. So I tried it. I opened Tex-Edit Plus, entered "netstat -na | grep 548" to see who is logged into my machine, saved it as "xyz.command" on my Desktop and made sure it was as a text document, opened Terminal, typed "chmod 774 ", dragged xyz.command into the Terminal window, pressed Enter, then quit the Terminal. I then double-clicked on xyz.command and all that occurred was that TextEdit opened the document and that was it. Nothing got executed. What am I missing?



[ Reply to This | # ]
don farrar's .command file
Authored by: pecosbill on May 19, '04 10:30:16PM

I strongly suspect you have a .txt or other extenstion that is hidden. I don't have TE+ but TextEdit (OS X) worked fine for me. I made a new document, set it to plain text (Format menu), and saved it as test.command. When I tried saving it as such, it asked me if I wanted to postpend .txt or use .command. If TE+ doesn't ask, just double check the extension via the Finder. The resultant icon looks like double terminal windows.

---
Pecos Bill



[ Reply to This | # ]
applescript & starting apps
Authored by: pecosbill on May 19, '04 10:36:08PM
activate will not only start an application, but it will also foreground it (or just foreground it if it is already running). I prefer using

tell application "MyApp"
 launch
end tell

which will start the app in the background and I can click on it when I see fit.

---
Pecos Bill

[ Reply to This | # ]