• Login
Community
  • Login

Rename files based on data from within

Scheduled Pinned Locked Moved General Discussion
3 Posts 3 Posters 299 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.
  • D
    Don Sullender
    last edited by Jun 12, 2023, 3:39 PM

    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

    P W 2 Replies Last reply Jun 12, 2023, 3:45 PM Reply Quote 0
    • P
      PeterJones @Don Sullender
      last edited by PeterJones Jun 12, 2023, 3:45 PM Jun 12, 2023, 3:45 PM

      @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
      • W
        wonkawilly @Don Sullender
        last edited by Jun 12, 2023, 7:17 PM

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