0

I have a file called execute.command. When I execute it by opening it. It runs from my users folder. I would like it to run in the folder where it is located. is that possible?

Himmators
  • 14,278
  • 36
  • 132
  • 223

2 Answers2

2

You must change the script to change working directory to script-location directory:

#!/bin/bash
cd "$(dirname "$0")"

More answers here : Bash script: set current working directory to the directory of the script

Community
  • 1
  • 1
Floriz
  • 61
  • 3
0

I added cd dirname $0 to the top of the command line. This will cd you into the correct folder. Here are more details.

http://hints.macworld.com/article.php?story=20041217111834902

Himmators
  • 14,278
  • 36
  • 132
  • 223