Menu

Path problems opening files from the cmd line

2005-08-23
2012-11-13
  • Nobody/Anonymous

    When I open files from the command line without a full path and then change directories and try to open some more notepad++ becomes confused and says it can't open the file. Also if I have a file opened from the command line without a full path and then open a file from the GUI it gets confused and says the 'non-path' file doesn't exist anymore.

    Any work around for this?

     
    • Nobody/Anonymous

      In my case (using NP++ version 4.0.1 under Windows XP) it even fails when I try

      C:\>"C:\Program Files\Notepad++\notepad++.exe" c:\test.txt

      or

      C:\>"C:\Program Files\Notepad++\notepad++.exe" "C:\test.txt"

      NP displays the message

      C:\test.txt doesn't exist. Create it?

      NP++ looks great, but I would like to be able to open a file from the command line.

      Best regards
      Maarten

       
      • Nobody/Anonymous

        If you are looking for a solution how to execute *.cmd files.

        1. Edit the file shortcut.xml.
           - Path
                  C:\Documents and Settings\%user%\Application Data\Notepad++\shortcuts.xml
           - Insert
                  <Command name="launch CMD" Alt="yes" Key="67">cmd.exe /K &quot;$(FULL_CURRENT_PATH)&quot;</Command>
          
           - or if you like the cmd in color just Insert        
                  <Command name="launch CMD" Alt="yes" Key="67">cmd.exe /t:ce /K &quot;$(FULL_CURRENT_PATH)&quot;</Command>
          
           - Save the file

        2. Close an reopen your editor

        3. open your *.cmd (the file you work on)

        4. Go to execute --> lauch CMD  (Your *.cmd file will be executed in a cmd window)

        marol

         
      • Nobody/Anonymous

        edut the environment variable PATH like
        PATH=%PATH%;"c:\program files\notepad++"

        Then you can start from command line with

        notepad++ c:\helloword.txt

         
    • Dave A.

      Dave A. - 2007-05-05

      The command line must specify the entire file location when sending it to notepad++. One batch file command line which does this is

         C:\Progra~1\notepad++\notepad++ %~f1

      This assumes notepad++.exe is located in C:\Program Files\notepad++.
      The %~f1 tells the command processor to use the full file name of the argument, including the path. Put this command in a .bat file somewhere it can be found (along the environment path) and it will cause notepad++ to use the correct location of the file. The only downside to using a batch file is the command line is captured by running notepad++ and does not free up until notepad++ closes. You can open a second command window and use it to run a compiler to process the file just edited and saved even though notepad++ is still open with it. For example: store the above line in a file called ed.bat (in the environment path). Then to edit myfile.xxx with notepad++, type "ed myfile.xxx" from within the directory where myfile.xxx is located.
      Dave A.

       
    • Dave A.

      Dave A. - 2007-05-06

      Update on using a .bat file to start notepad++. My previous and following methods run correctly on WinXP.
      Enter the following line into a .bat file which is in your environment path, such as C:\ed.bat:

         start C:\Progra~1\notepad++\notepad++.exe %~f1

      The start command initiates notepad++ with the file you specify. To use the command on myfile.java from the directory where myfile.java is located, type:

         ed myfile.java

      The path to the file will be supplied to notepad++ as an input parameter. The start command lets the command line release from notepad++ instead of waiting for it to terminate. This removes the downside mentioned in my previous message. Now the command line can be used to assemble or compile a file while notepad++ is running.
      Dave A.

       
    • Nobody/Anonymous

      anyone knows how to compiles and run the java files directly from the NOTEPAD++ without going to cmd.

      thanks

       
      • MJG

        MJG - 2007-03-19

        You still need the command line.

        You can run that command line with the "Run..." command under the Run menu.  You can bind that command to a shortcut key sequence by clicking the "Save..." button on the Run dialog.

        You may need to run two separate commands, one to compile your Java code, the other to run it when it compiles without errors.  --Joel

         
      • MJG

        MJG - 2007-03-19
         
    • Nobody/Anonymous

      I know how to setup that, but i was wondering if there is shortcut that i press Ctrl something and it will come out the cmd with the answer directly. because there was a shortcut for compiling java in the older version.  Anyway, thanks for your reply.

       
MongoDB Logo MongoDB