brainsteam.co.uk/brainsteam/content/posts/legacy/2015-06-28-tidying-up-xml-i...

1005 B
Raw Blame History

title author type date url categories tags
Tidying up XML in one click James post 2015-06-28T10:24:33+00:00 /2015/06/28/tidying-up-xml-in-one-click/
PhD
Work
processing
sapienta
tidy
xml

When Im working on Partridge and SAPIENTA, I find myself dealing with a lot of badly formatted XML. I used to manually run xmllint format against every file before opening it but that gets annoying very quickly (even if you have it saved in your bash history). So I decided to write a Nemo script that does it automatically for me.

#!/bin/sh

for xmlfile in $NEMO_SCRIPT_SELECTED_FILE_PATHS; do

    if [[ $xmlfile == *.xml ]]
     then
         xmllint --format $xmlfile > $xmlfile.tmp
        rm $xmlfile
        mv $xmlfile.tmp $xmlfile
    fi
done

Pop that in a file called “Tidy XML” in your ~/.local/share/nemo/scripts directory and when you inspect files with Nemo it should appear in the right click menu.