Manipulations on many files

  • 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++ ?





  • 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

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

  • @Rafal-Jonca-0

    adopt it to thousands of files

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

  • For 100 files your regex works great.

  • @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??

  • 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

  • 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

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

    So I must divide it to parts 100 files every.

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

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

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

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

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

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

  • @Alan-Kilborn

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

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

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

  • @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…


    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.

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

Log in to reply