Xml – Using powershell to turn a folder structure into an XML file


I've been downloading a bunch of music the lately(yes yes, perfectly legal)

Anyway, the random idea to turn the folderstructure into and XML file occured to me.
I don't know what I'd do with it, but I'd like to be able to do it.

So I turned to Windows Powershell. Turning any data into and XML file is done via:

$P = "command to get data"
$P | export-CliXML "where you want your XML file to be saved"

Still, I'm having trouble listing the folders. They're all saved on an external harddrive with the letter E, under the map "Music check later".

Can anybody help me here? I know that Get-ChildItem -Recursive is a part of it, but that's about as far as I'm getting here.

Best Solution

Are you looking for something as simple as:

Get-ChildItem -Recurse 'E:\Music check later' | Export-CliXML <outputfile>

Of course, the CliCML format outputs the XML as a Powershell object so you'll find a lot of extra information you may not need.

It might be worth your while using the output from GetChildItem to generate your own XML schema based on your needs.