0

I have a folder with a python script, supporting files (data that gets placed into the folder) and a .command file to launch the script.

The command file is simple:

cd /Users/me/Dropbox/MyBot
python do_automation.py

The problem is, I can't just have it be python script.py, I have to cd into the directory using absolute path first. This makes sharing it with others difficult as I have to change the path for the directory to match with where the folder has been copied to.

Is there not a way for the .command to just start in the folder/directory in which it is located? You'll note it's in a dropbox folder, that isn't important as I'm not sharing that specific folder with anyone, simply copying it all to their computer.

I would like to just copy the folder to anyone I want and have them simply click on the .command file to have it do the thing!

Tuvan
  • 1

1 Answers1

0

If .command files behave the same as .bat files, you can use this to CD to the directory of your .command file:

CD /d "%~dp0"

so the file would be

CD /d "%~dp0"
python do_automation.py

see this question to understand what each part of the command does.

AudioBaton
  • 361
  • 2
  • 6