如何使用Powershell获取目录路径 [英] how to get the directory path using powershell

查看:265
本文介绍了如何使用Powershell获取目录路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下语句时,我可以看到目录路径

When i execute the below statments, i can see the directory path

[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}




我的问题是如何仅获取不带前缀(@ {Directory =)和后缀(})的路径

您能否建议如何修改以下指令以获取预期的输出
说明:




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:

[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

推荐答案

PNGsDirectory = Get-ChildItem C:\ FileName \ * .png-递归|选择对象目录 for (
PNGsDirectory = Get-ChildItem C:\FileName\ *.png -recurse | Select-Object Directory for(


j = 0;
j=0;


j -lt
j -lt


这篇关于如何使用Powershell获取目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆