2

I am trying to get a run command set up in Notepad++ that will run the python file I have open in NP++ with the current_directory set to the folder containing the open script. It is not working, and I have hit a point where I can't figure out why.

I can get the run command to open CMD and change the directory appropriately with the following:

cmd /K cd "$(CURRENT_DIRECTORY)" 

This works as I expect, CMD open in the current directory, waiting for a command. I can type python in here and python starts in this cmd window!

I expect the following run command to do what the previous one did, then run python in the CMD window:

cmd /K cd "$(CURRENT_DIRECTORY)" python

But this does not work, it gives the error:

The system cannot find the path specified.

Does anyone know why this would be happening / what I must do instead to get python to run here?

3
  • 2
    cd "$(CURRENT_DIRECTORY)" python is an invalid command. Try chaining them cd "$(CURRENT_DIRECTORY)" & python
    – DavidPostill
    Commented Jul 3, 2019 at 17:52
  • You are my new favourite human!
    – Hoog
    Commented Jul 3, 2019 at 18:29
  • I wrote an answer (so it can be accepted) as comments are ephemeral.
    – DavidPostill
    Commented Jul 3, 2019 at 20:24

1 Answer 1

3

Does anyone know why this would be happening / what I must do instead?

cmd /K cd "$(CURRENT_DIRECTORY)" python

The above is an invalid command.

You should instead run the two commands sequentially using the & operator

cmd /K cd "$(CURRENT_DIRECTORY)" & python

commandA & commandB

Run commandA and then run commandB

Source Command Redirection, Pipes - Windows CMD - SS64.com

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .