Community
    • Login

    Rename files based on data from within

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 284 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.
    • Don SullenderD
      Don Sullender
      last edited by

      I have several hundred config files on a Windows 2019 Server that are named by their MAC address but want to rename them based on their extension which is located within.
      The original file is 14AEDB1A0DE1.cfg and I would like it named 2200.cfg which comes from this line within the file.
      user_name=06300000542200

      PeterJonesP wonkawillyW 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Don Sullender
        last edited by PeterJones

        @Don-Sullender ,

        That’s really not a task that a “text editor” is good at doing on its own.

        If you add on the PythonScript plugin, or one of the other scripting plugins, it’s possible. (In pythonscript, I would do an editor.research(r'user_name=\w+(....)\b', someFunction), and then define someFunction so that it uses the m.group(1) text to rename the file. But honestly, with the same amount of work, I could do it outside Notepad++ in the programming language of my choice, in probably 2-3 lines of real code, without requiring that the file be open in Notepad++ first)

        1 Reply Last reply Reply Quote 4
        • wonkawillyW
          wonkawilly @Don Sullender
          last edited by

          @Don-Sullender

          I don’t know win2019 server but what you ask is possible to be done even with just few rows of powershell or vbs code, if the OS has one of them.
          Also if the files you have to handle have a fixed schema will be relatively easy to implement a script.

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