tags:

views:

542

answers:

2

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.

+2  A: 

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.

Damien Ryan
Keep in mind that Export-CliXml exports 2 levels deep by default and can be increased using the -depth parameter.
Shay Levy
Depth Parameter you say. I'll look into it. Hopefully there's a "full depth" option.
WebDevHobo
+1  A: 

With PowerShell CTP3 you can use the ConvertTo-XML cmdlet. You'll need to know how deep your folder structure is in advance. By default the cmdlet convert the first level only. You can increase it with using the -Depth parameter.

Shay Levy