在 PowerShell 中获取文件的完整路径 [英] Get full path of the files in PowerShell

查看:138
本文介绍了在 PowerShell 中获取文件的完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取所有文件,包括属于特定类型的子文件夹中的文件.

I need to get all the files including the files present in the subfolders that belong to a particular type.

我正在做这样的事情,使用 Get-ChildItem:

I am doing something like this, using Get-ChildItem:

Get-ChildItem "C:\windows\System32" -Recurse | where {$_.extension -eq ".txt"}

但是,它只返回文件名而不是整个路径.

However, it's only returning me the files names and not the entire path.

推荐答案

添加 |选择 FullName 到上面一行的末尾.如果您之后需要对此进行实际操作,您可能需要将其通过管道传输到 foreach 循环中,如下所示:

Add | select FullName to the end of your line above. If you need to actually do something with that afterwards, you might have to pipe it into a foreach loop, like so:

get-childitem "C:\windows\System32" -recurse | where {$_.extension -eq ".txt"} | % {
     Write-Host $_.FullName
}

这篇关于在 PowerShell 中获取文件的完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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