创建一个文本文件,列出指向某个文件或通配符的所有路径。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创建一个文本文件,列出指向某个文件或通配符的所有路径。相关的知识,希望对你有一定的参考价值。
First of all, for all Stackoverflow.com members who have seen my question about this snippet on Stackoverflow, yes I am the same person as WebDevhobo. Last time I asked a question about something I posted here I got a bucketload of comments saying I couldn't claim the work of that snippet to be mine >_>This is a function for Windows Powershell. What this will do is create a list of all paths that lead to a certain file on your computer.
Example input: `listAllPaths c:\ *.zip c:\allZips.txt`
This will create a file allZips.txt under your root harddrive(the third parameter). The content will be a list of all paths to every file that ends with the characters .zip(second parameter) and Powershell will start looking from c:\(the first parameter)
You'll have to make sure Powershell knows the function first. So you'll have to add it to your Powershell profile, which will make it so that every time you start Powershell, you can use the function.
More info on the Powershell profile can be found [here][1]
[1]: http://superuser.com/questions/63446#63458
Function writeAllPaths([string]$fromFolder,[string]$filter,[string]$printfile) { Get-ChildItem -Path $fromFolder -Recurse $filter | Select-Object -Property FullName > $printfile }
以上是关于创建一个文本文件,列出指向某个文件或通配符的所有路径。的主要内容,如果未能解决你的问题,请参考以下文章