Sunday, June 18, 2017

windows - Running python scripts in their directory with Notepad++


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?


Answer



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


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...