简体   繁体   中英

Powershell how to get the full path of a folder that is deep in the folder structure by knowing only the beginning of the path

Would please anyone tell how I can get the path of a specific folder with Powershell command that is about 10, 15 places down in folder structure.

Eg In the following folder structure

C:\Folder1\Folder2\Folder3\...\....\....\....\....\.....\....\....\...\MyFolder

Here I have the starting folder path accessible ie.

C:\Folder1\Folder2\Folder3\

but I don't know the missing ...\\...\\....\\ folders.

I want to get the full path to the MyFolder. Any help doing that with Powershell?

Try this:

get-childitem -Path 'c:\Folder1' -Directory -Recurse | ? {$_.Basename -eq 'MyFolder'} | Select FullName

Or:

get-childitem -Path 'C:\folder1' -Directory -Recurse -Filter 'MyFolder' | Select FullName

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM