Community
    • Login

    Renaming and saving text files based on its content

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 455 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.
    • Sam CemS
      Sam Cem
      last edited by Sam Cem

      Hi,
      I’ve got hundreds of .html-Files of a Forum and I want to rename and save them the following way. Each File consists, among many other lines, of the following line:

      <td align="left" valign="middle" class="nav" width="100%"><span class="nav"><a href="index.php?sid=a6ddafec8f3ed8a0a7cf4f8bf8273cff" class="nav">ONE</a><a href="./index.php" class="nav">TWO</a>&nbsp;&raquo;&nbsp;<a href="./viewforum.php" class="nav">THREE</a><a href="./viewtopic.php" class="nav">FOUR</a></span></td>
      

      My goals: (THREE, FOUR are just a placeholders here and different in each file)

      1. Rename each file to “FOUR.html”
      2. save the file in directory: “Forum/THREE”

      How to do this in a smart way for all hundreds of files using Windows?
      Is it possible with Notepadd++, a Macro, a script, or better be done with Windows-PowerShell?

      Btw: I’ve Regex-Knowhow, so I’m able to create the final Regex myself. It’s just about what tools to use for.

      PeterJonesP dr ramaanandD 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Sam Cem
        last edited by

        @Sam-Cem ,

        Is it possible with Notepadd++, a Macro, a script, or better be done with Windows-PowerShell?

        Notepad++ macros cannot rename files, so Notepad++ cannot do this natively.

        You would either need to use one of the scripting plugins (like PythonScript) if you wanted to stay inside Notepad++, or use some external scripting language (like PowerShell) if you’re fine with that. I don’t see much benefit of doing it within Notepad++ using a scripting plugin, unless you’re more comfortable writing the code in Python than in PowerShell (and if you are, you could probably just as easily write it in normal Python code, without the PythonScript interface).

        1 Reply Last reply Reply Quote 2
        • dr ramaanandD
          dr ramaanand @Sam Cem
          last edited by dr ramaanand

          @Sam-Cem You can click and read How to replace a particular “url” with “url” of each webpage in multiple files using Notepad++? - I used the solution 2 mentioned at codeproject.com (the link to the codeproject.com webpage can be seen if you click the link I have mentioned above - do not click on the, “codeproject.com” link mentioned here).

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