Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

multi hierarchy folder create

$
0
0

Hi Scripting Guys!

  In some case i want Create multi hierarchy folder in a RootPath such as "E:\Test"

And the  structure of multi hierarchy folder get from a Folder_structure.csv file with two attribute-row below

[String]parent_directory and [String[]]Sub_directory

parent_directorySub_directory
a                        "1","2","4","5"
b                        "7","8","10","Tmp"
c                        "3","6","Test"

Finally i want to import Folder_structure.csv an in a loop create all the Sub_folders

$RootPath = "E:\Test" #RootPath
$Structure = Import-Csv 'E:\Folder_structure.csv' -Verbose 
$Structure| % {
    $ChildItemPath = $RootPath + "\" + $_.parent_directory
    $ChildItemPath
    cd $ChildItemPath
    $_.Sub_directory | % {New-Item -ItemType Directory -Path . -name $_ -Verbose -Force -ea 0}
    }
the statement  "$_.Sub_directory | % {New-Item -ItemType Directory -Path . -name $_ -Verbose -Force -ea 0" in the loop
I don't know how to make it work 


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>