Rename files based on data from within
-
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 -
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 definesomeFunction
so that it uses them.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) -
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.