Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

Powershell-Create folder inside a sub folder that is buried deep down and full path is not known

I want to create a folder inside a sub folder that is buried deep down. I don't know the full path but I know the folder name where I want to create this new directory.

Get Child-Item give me the full path of the desired folder but I can't get it working with New-Item command.

enter image description here

In the following snippet, I want to create new directory inside TempFolder and I want to achieve this in one line statement.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try This

$a=Get-ChildItem -Path c:empfolderafolderb -Recurse |? {$_.BaseName -eq "folderc"}
New-Item -Path $a.FullName -Name "folderd" -ItemType "directory" 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...