Community
    • Login

    Manipulations on many files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    22 Posts 3 Posters 5.5k 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.
    • Rafal Jonca 0R
      Rafal Jonca 0
      last edited by

      Hello,

      I have problem of this kind: I have many txt files like that A example. And I need to remove all the content from them, except first line, like in B example (leave only one line, but in many files). How to do it ? Can it be made with N++ ?

      A

      A.png

      B

      B.png

      1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse
        last edited by

        but make sure you have a backup in case something goes wrong.
        Regular expression search and replace with
        search: ^(.+?\R).+
        and replace: \1

        mark regular expression and . matches newline

        1 Reply Last reply Reply Quote 5
        • Rafal Jonca 0R
          Rafal Jonca 0
          last edited by Rafal Jonca 0

          Great, Ekopalypse, but how to adopt it to thousands of files ?

          I noticed there was a limit for the files already opened in NP++

          I wanted open thousands files and it was not possible. The limit is maybe 100 files at once. How to omit that ?

          Yes, I forgot to say that I need it for thousands of files :)

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • Alan KilbornA
            Alan Kilborn @Rafal Jonca 0
            last edited by

            @Rafal-Jonca-0

            adopt it to thousands of files

            The Find in Files tab of the Find dialog has a Replace in Files button.

            1 Reply Last reply Reply Quote 3
            • Rafal Jonca 0R
              Rafal Jonca 0
              last edited by

              For 100 files your regex works great.

              EkopalypseE 1 Reply Last reply Reply Quote 0
              • EkopalypseE
                Ekopalypse @Rafal Jonca 0
                last edited by Ekopalypse

                @Rafal-Jonca-0

                as Alan suggested, you might use “replace in files”.
                But I’m really surprised about that file limit you mentioned.
                May I ask you which npp version you are using?
                Can you post the debug info which is available from the last menu the ? menu?
                Maybe you run out of addressable memory??

                1 Reply Last reply Reply Quote 1
                • Rafal Jonca 0R
                  Rafal Jonca 0
                  last edited by

                  Ekopalypse, it works great :)

                  I must note it down somewhere, because it is important operation for me.

                  Heh, the problems maybe because I have 6.1.5 version :) 2012 year

                  Khem, I admit I am using N++ seldom, didn’t update it because there was no need before (!)

                  Perhaps it’s the time to update :D

                  1 Reply Last reply Reply Quote 4
                  • Rafal Jonca 0R
                    Rafal Jonca 0
                    last edited by

                    I confirm, Ekopalypse. There is still limit.

                    ver. 7.9.2, I am trying to open 804 files and it is not possible.

                    32GB RAM, Win 7

                    Files are very small, only one line of code every, 1KB

                    1 Reply Last reply Reply Quote 0
                    • Rafal Jonca 0R
                      Rafal Jonca 0
                      last edited by

                      Opening 100 files is possible and opening 200 files is not.

                      So I must divide it to parts 100 files every.

                      EkopalypseE 1 Reply Last reply Reply Quote 0
                      • EkopalypseE
                        Ekopalypse @Rafal Jonca 0
                        last edited by

                        @Rafal-Jonca-0

                        Now I remember about an issue about the file path length used
                        in dialogs like open files.
                        You do open these files by using file->open, correct?
                        If you open an explorer and select all files and drag and drop it
                        into npp it should work I guess.

                        1 Reply Last reply Reply Quote 1
                        • Rafal Jonca 0R
                          Rafal Jonca 0
                          last edited by

                          Right, I open them by File -> Open

                          You mean file path lenghts ? The path is not too long, it is something like “C:\Downloads\AAA”

                          The name of the files is also not too long - “index(XXX).html”

                          I am happy that I give a feedback. But I doubt other people will have need to open 800 files.

                          1 Reply Last reply Reply Quote 0
                          • Rafal Jonca 0R
                            Rafal Jonca 0
                            last edited by

                            Then I use a nice “Combine” plugin (stitch all of them to one) and make a list of urls in one file.

                            Alan KilbornA 1 Reply Last reply Reply Quote 0
                            • EkopalypseE
                              Ekopalypse
                              last edited by

                              @Rafal-Jonca-0

                              No, I mean npp uses this win32 API function
                              and each file you select is summed up to a total size.
                              When this size is reached, no more files will be added and you will see only a subset of the open files you originally selected.

                              Drag and drop from Explorer works differently and therefore does not have this limitation.

                              1 Reply Last reply Reply Quote 1
                              • Rafal Jonca 0R
                                Rafal Jonca 0
                                last edited by

                                Ahh, so it’s clear. I am afraid I will not remember this, as I use this kind of manipulations maybe once per year.

                                But I can do it in this or other way. So no problem.

                                Thank you all for help.

                                1 Reply Last reply Reply Quote 0
                                • Alan KilbornA
                                  Alan Kilborn @Rafal Jonca 0
                                  last edited by

                                  @Rafal-Jonca-0

                                  It is silly to open (into N++) all of these files, if all we are talking about is the need for the original purpose of this thread. Use Replace in Files – the files do NOT need to be open for this to work.

                                  EkopalypseE 1 Reply Last reply Reply Quote 1
                                  • EkopalypseE
                                    Ekopalypse @Alan Kilborn
                                    last edited by

                                    @Alan-Kilborn

                                    with open files you can undo changes which, afaik, can’t be done when using “replace in files”.

                                    1 Reply Last reply Reply Quote 0
                                    • Rafal Jonca 0R
                                      Rafal Jonca 0
                                      last edited by

                                      Ahh, silly ? Alan, so when I have url in every of html files in content and I should prepare a list of them, so what I should I do ? Free Download Manager needs a one list.

                                      1 Reply Last reply Reply Quote 0
                                      • Rafal Jonca 0R
                                        Rafal Jonca 0
                                        last edited by

                                        Or you expect I will open every of 804 files and add their url to FDM manually ? ;)

                                        Alan KilbornA 1 Reply Last reply Reply Quote 0
                                        • Alan KilbornA
                                          Alan Kilborn @Rafal Jonca 0
                                          last edited by

                                          @Rafal-Jonca-0

                                          needs a one list

                                          Not sure how you’re going to obtain “one list” this way.
                                          Probably there are some missing details in what you’re doing that haven’t been conveyed in the flow of this thread – an “XY problem” looms here, perhaps?
                                          Anyway, I hope it all works out for you…

                                          @Ekopalypse

                                          with open files you can undo changes which, afaik, can’t be done when using “replace in files”.

                                          Yes, but you already cautioned about having a backup, so I thought you and I were on the same track with this being a RIF problem/solution.

                                          Rafal Jonca 0R 1 Reply Last reply Reply Quote 2
                                          • EkopalypseE
                                            Ekopalypse
                                            last edited by Ekopalypse

                                            At the beginning yes, but then I had the impression that Rafal wants to open the files explicitly. Maybe for this case - but I’m not really sure.

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