-1

Is there a way to create a command in Windows 7 command line to open some text file in selected text editor? E.g. pspad "text file location" that will open text file in PSPad.

Art Gertner
  • 7,429
user46581
  • 107

2 Answers2

0

Not sure if I understood the question correctly, but if I did, then you have just answered your own question with this line:

E.g. pspad "text file location" that will open text file in PSPad

That is exactly what you need. Most programs that are designed to open the files of some format take the URL of the file as the CMD argument. So supplying the path to the file after the name of the program will do exactly what you want.

Few things to consider:

  • Make sure that the location of the executable is known to the system. It has to be in $PATH variable. Otherwise you will need to specify a full path to executable
  • You can use absolute or relative path to text file, but if you are using relative path, then be aware of your current working directory

Here is the syntax for running PSPad from cmd:

"drive:\path\PSPad.EXE" [/switch -switch] "file1" ["file2" ...]

This example show the use of absolute path to executable. If you don't want to use full path to executable then add it to your $PATH variable. If you are unfamiliar with the environment variables, then here is a very comprehensive guide.

You can read more about command line parameters for PSPad here

Art Gertner
  • 7,429
0

If your textfiles (*.txt) already are associated with pspad, you can use the following command to do just that:

start mytext.txt

The command start will start a program with optional parameters. If you ask to launch a file, it will instead open that file by the associated program in windows. If you use start followed by a path (directory) with no file, the default for showing paths will be used to show you that path. By default that is explorer. So start . will open the current folder in explorer.

LPChip
  • 66,193