Open files & keyword search&Proc...

  • Anonymous - 2012-04-10

    Dear All,

    Can someone please help me out in generating a macro to open the files (in notepad++.exe) associated with a particular "INCLUDE" statement and also Find/search the uer-input keyword and process the opened files accordingly?

    Algorithm: for your kind reference.
    1. a) If the macro1 is run in a notepad++.exe, it should search for the INCLUDE statements available inside the current file and open all files associated with the INCLUDE statements.
    for example: INCLUDE 'C:/test1/A_01_prog.txt' - this statement will be avilable in the current notepad file.
    All files are available in folders, say A, B, C and the macro should be capable of searching 'n' number of subfolders inside the main folder)
    b) All the files (in the INCLUDE statement) should be opened in a single Notepad++ session

    2. a) If the macro2 is run, it should find a specified text (user enter via a GUI) in all files opened in Notepad++ session. i.e., In the dialog box, text or number to be found is entered. (Regular expressions can be used - eg. (1234 l 7890 means look for 1234 or 7890).
    This macro should also close all files in Notepad++ session which doesn't have the specified text

    Finally, please use the generic path as C:/test1/ to reference all files. Please find the "" in the link attached below. - just for your reference. (I guess this macro can be developed without these sample files too)
    Unzip the attached "" and process the files accordingly.

    Requesting you to please get me for the macro satisfying te above algorithm.

    Thanks in advance!

  • Dave Brotherstone

    To open a file, use

    To get the text of the current line, use


    See notepad.prompt() for prompting the user for input. 

    I think you'd have more luck if you had a go at writing this, and ask when/if you get stuck - you might get lucky and find someone wanting a challenge though…. :)


  • Anonymous - 2012-04-16

    Hi Dave,

    Thank you for your response.

    But my Macro code requirement is a bit different as mentioned in my original post. I have written down a macro in "Nedit text editor" for the Algorithm 1 mentioned in my previous post. Code is as follows:
    find ("(?<=^INCLUDE').*?(?=')","forward","regex","wrap")

    For Algorithm 2, macro written in Nedit text editor is as follows:
    * Ask the user what to look for to fill with
    finditem = string_dialog("find?", "OK", "Cancel")
    if($string_dialog_button ==2 !! $string_dialog_button == 0)

    window = focus_window("last")
    # do your work here
    # raise_window()

    I guess the code written above is self-explanatory and you could find the algorithm explanation in my previous post.
    Could you please modify the above code so that these macros work with notepad++. As I am a new user of notepad, I am not much aware of the syntax of each commands being used.

    Please let me know if you have any questions.

    Thanks in Advance,

  • Dave Brotherstone

    Sorry, this is a help forum, for people with specific questions or issues relating to the Python Script plugin, not a free script writing service.  If I (and everyone else that writes scripts regularly) wrote everyone elses scripts, we'd never do anything else. There is ample documentation to get you started, and converting your existing script should just be a matter of changing the syntax, and the few N++/scintilla specific calls.

    If you want me to write this, that's a commercial request, and it would be 100 euros.



Log in to post a comment.