Create folder directory from path?

directory, powershell, powershell-2.0

Solution

Using the `-force` param, you can create all the folder in the tree in one action.

New-Item -ItemType directory C:\Folder1\Folder2\Folder3\Folder4 -Force

`md` is the alias to the function `mkdir` that call `New-Item` CmdLet.

Problem

I currently have a large list of folder paths that I want to use Powershell to create programatically. However my knowledge of Powershell, while growing, is still small. E.G. - The given path is: ``` C:\Folder1\Folder2\Folder3\Folder4 ``` I want to physically create this folder path using Powershell. Not all of the file paths have the same amount of levels. I get the basic concepts of reading the contents of the text file and making a directory: ``` get-content c:\folderPaths.txt | Foreach-Object{ MD newFolder } ``` However I am not sure how I can parse the Folder path to get each level of the new directory.

Original source