Run Notepad++ as commandline to edit and save
-
I have a folder of XML files, created without Linefeeds.
I want to run a script likeNotepad++ abc.xml XML Tools>PrettyPrint Notepad++ bcd.xml XML Tools>PrettyPrint Notepad++ cde.xml XML Tools>PrettyPrint Notepad++ def.xml XML Tools>PrettyPrint Notepad++ efg.xml XML Tools>PrettyPrintso they are all readable
Can I do this?
-
Not currently (from the command-line, anyway; see @FreeMeow’s reply, below, for an alternative).
Notepad++ has the
-pluginMessagecommand-line option, but XML Tools does not currently check that message; if the plugin author ever decided to add that feature, it would be technically feasible, but you would have to request that the plugin author implement that feature -
@Ian-Hicks

You can open all the xml files with Notepad++, check “Apply to all open files” under XML Tools, and then do PrettyPrint and it will activate for all the open files.
Afterwards your can disable it back, so you won’t accidently do it on all files needlessly. -
Thank you. You have improved the task, so it’s now just a few manual steps. A pity, as I was wanting to fully automate the extraction/processing path.
-
Dang…
You have now set me off on another problem.
While I wanted to be able to fully automate the process, I am happy to be able to do this with a “few” keystrokes.SO, I should be able to:
Notepad++ -nosession *.xml
and manually update all the files with a single action?
BUT:
Since the files are in a number of sub-folders, how do I get it to load a list of files?
It’s many more files/folders than this, but in essence:Notepad++ -nosession “abc.xml, .\folder1\bcd.xml, .\folder1\cde.xml”
-
@Ian-Hicks
http://stackoverflow.com/questions/2568310/ddg#2662761param( [string] $inputFile = $(throw "Please enter an input file name"), [string] $outputFile = $(throw "Please supply an output file name") ) $data = [xml](Get-Content $inputFile) $xws = new-object System.Xml.XmlWriterSettings $xws.Indent = $true $xws.IndentChars = " " $xws.NewLineOnAttributes = $true $data.Save([Xml.XmlWriter]::Create($outputFile, $xws))Take that script, save it as
formatxml.ps1. Then, from a PowerShell prompt type the following:formatxml.ps1 UglyFile.xml NeatAndTidyFile.xml -
@Ian-Hicks said in Run Notepad++ as commandline to edit and save:
It’s many more files/folders than this, but in essence:
In practicality, your “in essence” is the way to do it in Notpead++. Open all the files you want, in whatever normal command-line or GUI method you like using for opening multiple files, then use the XML Tools plugin command to do the pretty print on all the open XML files.
There isn’t another way in the native “Notepad++ & XML Tools” setup to do what you want.
@h-jangra showed you a way to do it for a single file (and assumed you’d be able to extend it to work on your mulitple files) completely outside Notepad++… but as that’s a non-Notepad++ solution, if you have any questions about it, or if it doesn’t do exactly what you want or you want to customize it, you would have to go to the original Stack Overflow post and/or create your own question there or elsewhere, because non-Notepad++ solutions are off-topic for this Notepad++ forum.
Inside Notepad++, if you added one of the scripting plugins (like Python Script), you could write a script that would open all the XML files you wanted, then run the XML Tools command to pretty-print all the open XML files, then save them and close them. (You could either write the script to open all, pretty print all, save all, close all; or to loop “for every file, open it, pretty print it, save and close, then move on to next file”; I don’t know which would be faster. If there are hundreds of files, it might be more memory efficient to write the script to do it one at a time, but that’s just a guess.)