powershell - Create Directory with ls and Create-Item -
i wanted create in directory same folders of directory (which contains 234 folders).
my ideas was
ls -name | new-item -itemtype directory -path d:\test\
i multiple times error d:\test
path exsits.
this doesn't work, directory creation part new-item -itemtype
never uses value pipeline.
what's more, don't filter output ls
, non-directory files processed too.
# list of folders gci | ? { $_.psiscontainer } | % { # create dir. uses join-path , $_.name combine new root dir directory's name new-item -itemtype directory -path $(join-path "d:\myroot" $_.name) }
Comments
Post a Comment