Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i execute the below statments, i can see the directory path
SQL
[array]$PNGsDirectory = Get-ChildItem C:\FileName\ *.png -recurse | Select-Object Directory
for($j=0; $j -lt $PNGfiles.Count; $j++) {Write-Host $PNGsDirectory[$j]}

result:
@{Directory=C:\FileName\images\junk1\images}
@{Directory=C:\FileName\images\junk2\images}
@{Directory=C:\FileName\images\junk5\images}
@{Directory=C:\FileName\images\junk7\images}



my Question is how to get only path without prefix(@{Directory=) and suffix(})

Can you suggest how to modify the below instruction to get the expected output
instruction:
C++
[array]$PNGsDirectory = Get-ChildItem C:\FileName\ *.png -recurse | Select-Object Directory

expected:
C:\FileName\images\junk1\images
C:\FileName\images\junk2\images
C:\FileName\images\junk5\images
C:\FileName\images\junk7\images
Posted
Updated 10-Sep-11 17:32pm
v2

1 solution

Not entirely sure what you are trying to achieve, but try something like this:

[array]$PNGsDirectory = Get-ChildItem C:\FileName\ *.png -recurse | Select-Object Directory
foreach($Directory in $PNGsdirectory) {Write-Host $Directory.Directory.FullName}


$PNGsDirectory contains PSCustomObjects so you need $Directory.Directory.FullName.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900