generating mkdir commands from a full directory listing. Is this possible? How?

x509

2[H]4U
Joined
Sep 20, 2009
Messages
2,630
I would like to generate all the mkdir statements automatically for a dir *.* /s command output. Is that feasible? I could not find such a utility, but maybe I was using the wrong search terms.

In advance, thanks.
 
So you're saying you want some sort of command to create a nested directory structure?
 
$strTargetDir = "c:\pathtosomewhere"
$listOfDirs = Get-ChildItem -Path $strTargetDir -Directory -Recurse
$listOfDirs | ForEach-Object {write-host "mkdir" $_.FullName}

Rub a little PowerShell on it to generate a list of mkdir statements for a target directory's descendants.
 
Xcopy is built into windows and can do that.

Code:
xcopy <source> <destination> /T /S /E

/T = Create directory structure, but don't copy files
/S = Process recursively
/E = Include Empty folders

xcopy is listed on the page I linked to.
 
Back
Top