• Login
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.
  • R
    Rafal Jonca 0
    last edited by Jan 15, 2021, 8:11 AM

    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
    • E
      Ekopalypse
      last edited by Jan 15, 2021, 12:22 PM

      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
      • R
        Rafal Jonca 0
        last edited by Rafal Jonca 0 Jan 15, 2021, 1:39 PM Jan 15, 2021, 1:38 PM

        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 :)

        A 1 Reply Last reply Jan 15, 2021, 1:39 PM Reply Quote 0
        • A
          Alan Kilborn @Rafal Jonca 0
          last edited by Jan 15, 2021, 1:39 PM

          @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
          • R
            Rafal Jonca 0
            last edited by Jan 15, 2021, 1:40 PM

            For 100 files your regex works great.

            E 1 Reply Last reply Jan 15, 2021, 1:44 PM Reply Quote 0
            • E
              Ekopalypse @Rafal Jonca 0
              last edited by Ekopalypse Jan 15, 2021, 1:45 PM Jan 15, 2021, 1:44 PM

              @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
              • R
                Rafal Jonca 0
                last edited by Jan 15, 2021, 8:23 PM

                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
                • R
                  Rafal Jonca 0
                  last edited by Jan 16, 2021, 4:38 PM

                  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
                  • R
                    Rafal Jonca 0
                    last edited by Jan 16, 2021, 4:41 PM

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

                    So I must divide it to parts 100 files every.

                    E 1 Reply Last reply Jan 16, 2021, 4:59 PM Reply Quote 0
                    • E
                      Ekopalypse @Rafal Jonca 0
                      last edited by Jan 16, 2021, 4:59 PM

                      @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
                      • R
                        Rafal Jonca 0
                        last edited by Jan 16, 2021, 5:34 PM

                        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
                        • R
                          Rafal Jonca 0
                          last edited by Jan 16, 2021, 5:35 PM

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

                          A 1 Reply Last reply Jan 16, 2021, 5:58 PM Reply Quote 0
                          • E
                            Ekopalypse
                            last edited by Jan 16, 2021, 5:50 PM

                            @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
                            • R
                              Rafal Jonca 0
                              last edited by Jan 16, 2021, 5:57 PM

                              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
                              • A
                                Alan Kilborn @Rafal Jonca 0
                                last edited by Jan 16, 2021, 5:58 PM

                                @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.

                                E 1 Reply Last reply Jan 16, 2021, 5:59 PM Reply Quote 1
                                • E
                                  Ekopalypse @Alan Kilborn
                                  last edited by Jan 16, 2021, 5:59 PM

                                  @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
                                  • R
                                    Rafal Jonca 0
                                    last edited by Jan 16, 2021, 6:00 PM

                                    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
                                    • R
                                      Rafal Jonca 0
                                      last edited by Jan 16, 2021, 6:02 PM

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

                                      A 1 Reply Last reply Jan 16, 2021, 6:11 PM Reply Quote 0
                                      • A
                                        Alan Kilborn @Rafal Jonca 0
                                        last edited by Jan 16, 2021, 6:11 PM

                                        @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.

                                        R 1 Reply Last reply Jan 16, 2021, 6:25 PM Reply Quote 2
                                        • E
                                          Ekopalypse
                                          last edited by Ekopalypse Jan 16, 2021, 6:21 PM Jan 16, 2021, 6:20 PM

                                          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
                                          6 out of 22
                                          • First post
                                            6/22
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors