• Login
Community
  • Login

open selected file in default application

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
24 Posts 5 Posters 8.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E
    Edificio Rascacielos Tenerife
    last edited by Mar 9, 2020, 11:20 AM

    I recently installed notepad++ on my laptop.
    I would like to open a path proposed in the txt file selecting and right click with the option.

    How can I do that ?

    1 Reply Last reply Reply Quote 0
    • P
      PeterJones
      last edited by Mar 9, 2020, 1:42 PM

      I thought it was enabled already: yeah, it’s in the default contextMenu.xml .

      Highlight the text. Right click. Near the bottom, there should be a line that says Open File. If there is that menu option, that should open the file. Let us know if you have that entry but it doesn’t open the file for you. (In that case, it might have to do with the filename having spaces or other weird characters, or something else similar.)

      If there isn’t that menu entry, run Settings > Edit popup ContextMenu. Look for and/or add the line

          <Item MenuEntryName="Edit" MenuItemName="Open File"/>
      

      … somewhere near the end of the file. Save. Exit Notepad++ and restart.

      1 Reply Last reply Reply Quote 2
      • E
        Edificio Rascacielos Tenerife
        last edited by Mar 10, 2020, 8:35 AM

        Don’t go well with that option

        P:\Escritorio\Grupo a desempaquetar\Mi Whatsapp\Caratulas CINECLUB\CINE LUNES\AsusPortatil - 09_03_2020 , 12_10_17.png
        O:\PANTALLAZOS\2020\03.2020

        fails in both cases.
        the open file option I think is designed to open txt files types. When I apply to open the png file opens like a txt file .

        In the second case the folder don’t open and not interaction. …

        1 Reply Last reply Reply Quote 0
        • E
          Edificio Rascacielos Tenerife
          last edited by Mar 10, 2020, 8:39 AM

          I have tried this in another similar program with the option : Open selected file with default application. And does well.

          So I think this may be done with an addon or similar.
          But sure notepad++ can do.

          It is true ?

          A 2 Replies Last reply Mar 10, 2020, 12:20 PM Reply Quote 0
          • A
            Alan Kilborn @Edificio Rascacielos Tenerife
            last edited by Mar 10, 2020, 12:20 PM

            @Edificio-Rascacielos-Tenerife

            I think Peter hit on it earlier when he said “it might have to do with the filename having spaces”.

            Did you highlight/(select) the text of the path to the file before using this manner to attempt to open it?

            1 Reply Last reply Reply Quote 1
            • A
              Alan Kilborn @Edificio Rascacielos Tenerife
              last edited by Mar 10, 2020, 12:29 PM

              @Edificio-Rascacielos-Tenerife

              Oh, wait, I read closer what you said:

              When I apply to open the png file opens like a txt file

              Well, what do you expect from a text editor like Notepad++? It’s world is text :-)

              What you seem to be looking for here is maybe some sort of “ShellExecute”. This is likely possible, but not without some custom setup (e.g. Run menu).

              In the second case the folder don’t open

              For this one, you can “sort of” do it with Notepad++. If you invoke Edit (menu) > On Selection > Open Containing Folder in Explorer , you will get an Explorer window in the parent window of the chosen folder (with the chosen folder selected).

              1 Reply Last reply Reply Quote 2
              • E
                Ekopalypse
                last edited by Mar 10, 2020, 12:31 PM

                I assume OP wants to open the selected text with the default application.
                If this is the case there are two steps involved to make it work
                with context.menu.

                1. create a run menu entry: cmd /c "start $(CURRENT_WORD)"
                  and save it with a meaningful name. I chose OpenWithDefaultApp
                2. Settings->Edit Popup Context Menu and add <Item MenuEntryName="Run" MenuItemName="OpenWithDefaultApp"/>

                Restart npp.

                A E 2 Replies Last reply Mar 10, 2020, 12:38 PM Reply Quote 2
                • A
                  Alan Kilborn @Ekopalypse
                  last edited by Mar 10, 2020, 12:38 PM

                  @Ekopalypse

                  How about relative paths in the selected text? :-)

                  1 Reply Last reply Reply Quote 1
                  • E
                    Ekopalypse
                    last edited by Mar 10, 2020, 12:57 PM

                    Depends whether the path is always relative to one directory I guess.

                    A 1 Reply Last reply Mar 10, 2020, 1:01 PM Reply Quote 0
                    • A
                      Alan Kilborn @Ekopalypse
                      last edited by Mar 10, 2020, 1:01 PM

                      @Ekopalypse

                      I found a problem with the suggested Run menu entry. It doesn’t work for folders with embedded spaces. :-(

                      1 Reply Last reply Reply Quote 1
                      • P
                        PeterJones
                        last edited by Mar 10, 2020, 1:08 PM

                        @Ekopalypse said

                        cmd /c "start $(CURRENT_WORD)"

                        @Alan-Kilborn said,

                        It doesn’t work for folders with embedded spaces

                        This variant works for me: cmd /c "$(CURRENT_WORD)", even when both the folder and filename have a space, like with:

                        C:\Users\peter.jones\AppData\Local\Temp\space folder\space name.bmp
                        
                        E 1 Reply Last reply Mar 10, 2020, 1:14 PM Reply Quote 1
                        • E
                          Ekopalypse @PeterJones
                          last edited by Ekopalypse Mar 10, 2020, 1:15 PM Mar 10, 2020, 1:14 PM

                          @PeterJones, @Alan-Kilborn, @Edificio-Rascacielos-Tenerife

                          it seems that even cmd is not required, just "$(CURRENT_WORD)",
                          at least on windows7 this is working for me.

                          1 Reply Last reply Reply Quote 1
                          • E
                            Ekopalypse
                            last edited by Mar 10, 2020, 1:23 PM

                            I guess this and that explains why it doesn’t need a cmd shell at all.

                            Quote from MSDN:
                            open - Launches an application. If this file is not an executable file, its associated application is launched.

                            1 Reply Last reply Reply Quote 1
                            • E
                              Edificio Rascacielos Tenerife
                              last edited by Mar 10, 2020, 6:21 PM

                              I have opened a txt file with another text editor …

                              I put a screenshot : http://imagizer.imageshack.com/img924/4857/uZvuc1.png

                              do you see the option ?
                              I have selected in the text file a path to the desktop
                              and when selecting the option I can open that path

                              The same with a path to a pdf file : open the pdf with the default program
                              The same with a path to an image : open the image with the default program to see the images…

                              1 Reply Last reply Reply Quote 0
                              • E
                                Edificio Rascacielos Tenerife @Ekopalypse
                                last edited by Mar 10, 2020, 6:31 PM

                                @Ekopalypse said in open selected file in default application:

                                I assume OP wants to open the selected text with the default application.
                                If this is the case there are two steps involved to make it work
                                with context.menu.

                                1. create a run menu entry: cmd /c "start $(CURRENT_WORD)"
                                  and save it with a meaningful name. I chose OpenWithDefaultApp
                                2. Settings->Edit Popup Context Menu and add <Item MenuEntryName="Run" MenuItemName="OpenWithDefaultApp"/>

                                Restart npp.

                                Ufff. I was thinking in an addon or something. In the example I put above that option comes with the text editor . Surely must be something similar for npp

                                E 1 Reply Last reply Mar 10, 2020, 6:55 PM Reply Quote 0
                                • P
                                  PeterJones
                                  last edited by Mar 10, 2020, 6:52 PM

                                  @Edificio-Rascacielos-Tenerife said in open selected file in default application:

                                  I was thinking in an addon or something.

                                  Apparently you didn’t understand. @Ekopalypse solution used two builtin features of Notepad++.

                                  1. Use Run > Run
                                  2. type "$(CURRENT_WORD)" (with the quotes) in the The Program to Run box
                                    cf9c46c3-a113-45f9-b049-fa73c3228686-image.png
                                  3. Click Save…. Give it the name OpenWithDefaultApp and hit OK 5f8ee26e-afee-4ccb-9706-fb142b270a8e-image.png
                                  4. hit cancel to get out of that box
                                  5. Settings > Edit Popup Context Menu
                                  6. Down near the end, maybe just before </ScintillaContextMenu>, add <Item MenuEntryName="Run" MenuItemName="OpenWithDefaultApp"/>
                                  7. Save
                                  8. Exit
                                  9. Reload Notepad++

                                  Now that you’ve set it up, highlight your filename, right click to bring up the context menu, and select OpenWithDefaultApp. If the filename was a .png, it will open up your default png-image editing application with that filename. I thought that’s what you wanted.

                                  1 Reply Last reply Reply Quote 2
                                  • E
                                    Ekopalypse @Edificio Rascacielos Tenerife
                                    last edited by Mar 10, 2020, 6:55 PM

                                    @Edificio-Rascacielos-Tenerife

                                    there is no need for an addon as npp can do it using run menu.

                                    Run->run… and add "$(CURRENT_WORD)"

                                    ec6b62e3-5ec7-443a-a32a-1c57edd3d7dd-image.png

                                    press Save... and give it a meaningful name like OpenWithDefaultApp

                                    1f6b8e6d-5f17-4e84-8b2b-778c390285b0-image.png

                                    Now you can already open selected paths with run menu

                                    1e17f6f9-8165-42c8-b987-c3d2d42d1b7a-image.png

                                    If you want to add it to the context menu do

                                    c8d40831-6db8-4408-b75a-5d2be655f917-image.png

                                    and put the following into it <Item MenuEntryName="Run" MenuItemName="OpenWithDefaultApp"/>

                                    Then you have

                                    2fcd3d17-bcda-42f3-a31e-ca3fae034266-image.png

                                    1 Reply Last reply Reply Quote 2
                                    • guy038G
                                      guy038
                                      last edited by Mar 10, 2020, 8:05 PM

                                      Hello, @edificio-rascacielos-tenerife, @peterjones, @alan-kilborn, @ekopalypse and All,

                                      I tested the various syntaxes, to put in the The Program to Run box, after hitting the F5 key, on my old Windows XP SP3 laptop !

                                      And it happened that using the cmd and/or the Start commands did not work properly, in some cases, when filename and/or path contain spaces !


                                      Finally, using the simple syntax "$(CURRENT_WORD)" and, even, the syntax $(CURRENT_WORD), without the double quotes " are just fine, in all cases :

                                      • when selecting an absolute path with/without space(s) ( for instance, Drive Letter:\----\-- --\----\-- --.jpg )

                                      • when selecting a relative path with/without space(s) ( for instance ( \----\-- --\----\-- --.jpg )

                                      • when selecting only a filename with/without space(s) ( for instance, -- --.jpg )

                                      Remark : Even if these paths or filenames are, themselves, embedded between double quotes ", the result is still correct, with the two syntaxes "$(CURRENT_WORD)" or $(CURRENT_WORD) and the filename is opened with its default application ;-))

                                      Best Regards,

                                      guy038

                                      1 Reply Last reply Reply Quote 2
                                      • E
                                        Edificio Rascacielos Tenerife
                                        last edited by Mar 10, 2020, 8:51 PM

                                        Well I am going to try.

                                        I think above is the answer.
                                        Why don’t you put this in the contextual menu for the npp version ? for no programmers like me may be the best solution !

                                        Nevertheless I gonna try and comments.

                                        It seems to me easier at a first glance try to follow the Ekopalypse’s instructions…

                                        1 Reply Last reply Reply Quote 0
                                        • E
                                          Edificio Rascacielos Tenerife
                                          last edited by Mar 10, 2020, 9:02 PM

                                          Done !
                                          My first attempt was not good. I try only vary the contextual menu but runs nothing.
                                          Then I put the environment in english and try to create the script to run the program OpenWithDefaultApp
                                          with the line : “$(CURRENT_WORD)”

                                          Then reopen the program all began to work.

                                          Best regards

                                          1 Reply Last reply Reply Quote 0
                                          3 out of 24
                                          • First post
                                            3/24
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors