Learning Curve
Learning Curve

Reputation: 1569

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.

E.g. In the following folder structure

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

Here I have the starting folder path accessible i-e.

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?

Upvotes: 0

Views: 321

Answers (1)

Scepticalist
Scepticalist

Reputation: 3923

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

Upvotes: 3

Related Questions