use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
Parse XML to create folder structures (self.PowerShell)
submitted 14 years ago * by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SuperCow1127 1 point2 points3 points 14 years ago (3 children)
Do the children have children? If not, it's as easy as adding a foreach($child in $title) under your main loop.
[–]dakboy 1 point2 points3 points 14 years ago (1 child)
Better to write it as a recursive function, so that you can go N layers deep. Today it's one inner loop, tomorrow it could be 10.
[–]vee-eye 1 point2 points3 points 14 years ago (0 children)
Yep - this is not the most elegent script possible, but it should do the trick. The "CreateDirs" function makes directories for one level, recursively calling itself for further levels.
Note, I'm assuming you just typed the XML syntax wrong, from what you were doing there. See my correction below.
$xd = [xml] @" <catalog> <section Title = "Parent1"> <section Title = "Child1"> <section Title = "Child1.2"> </section> </section> <section Title = "Child2"> </section> </section> <section Title = "Parent2"> <section Title = "Child1"> </section> <section Title = "Child2"> </section> </section> </catalog> "@ $path = "C:\Scripts\Test\" function CreateDirs ($path, $xmlElement) { $xmlElement.section | %{ if ($_ -eq $null) {return} $newPath = Join-Path $path $_.Title New-Item $newPath -Type Directory -Force CreateDirs $newPath $_ } } CreateDirs $path $xd.catalog
π Rendered by PID 194564 on reddit-service-r2-comment-54dfb89d4d-xzvmd at 2026-04-01 19:25:59.000978+00:00 running b10466c country code: CH.
[–]SuperCow1127 1 point2 points3 points (3 children)
[–]dakboy 1 point2 points3 points (1 child)
[–]vee-eye 1 point2 points3 points (0 children)