Delete All Files Not Referenced by an XML file

I would like to compare the contents of a directory minus file extensions to an XML file and delete all files not referenced by the XML file. What is the easiest way to do this?

If youre married to xml, a quick python script might be your best bet.

To expound on this, there’s an xml parsing Lib. You can use that to create an array of “files in xml” and then use os.walk to walk the directory and check each file in the tree against your xml’s list.

1 Like

Whatewer your solution is op post a pastebin. I could use a tool like this for… well any file type really.

@Sea_Monkey Golang provides XML parsing as a part of its standard library, which is pretty nice and could be easily implemented for your needs. @FaunCB Golang provides a lot of parsers under the encoding package which is very easy to use, directly or indirectly through interfaces.

https://golang.org/pkg/encoding/xml/

Someone already made a tool for my specific use case - HyperspinChecker, so I’ll mark this as solved.