1

I've set up this script:

#!/bin/bash
/Applications/NameChanger.app/Contents/MacOS/NameChanger "$@"
osascript -e "delay 1" -e "tell application \"NameChanger\" to activate"

I'm using it to pass file names to NameChanager. Without the second line it loads NameChanger unfocused. I thought I should use a delay and then activate with applescript to get it focused.

Unfortunately the script is "waiting" for NameChanger to run and then to exit before executing the applescript bit. How can I change that?

cwd
  • 53,018
  • 53
  • 161
  • 198

2 Answers2

3

Alternatively you can use the open command to launch NameChanger. This should also automatically bring NameChanger to the foreground:

#!/bin/bash
open /Applications/NameChanger.app --args "$@"
sakra
  • 62,199
  • 16
  • 168
  • 151
2

Append a & at the end of commands in a shell script that you want to run in the background.

/Applications/NameChanger.app/Contents/MacOS/NameChanger "$@" &
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • for some reason i didn't think that would work, but it did! Thanks! While you're at it can you look at this one? http://stackoverflow.com/questions/3169805 I don't think it has a real answer yet. I also proposed some edits. – cwd Jul 01 '11 at 13:40
  • 1
    I'd say the given answer is accurate. – Ignacio Vazquez-Abrams Jul 01 '11 at 13:42