创建一个文本文件,列出指向某个文件或通配符的所有路径。

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
  1. Function writeAllPaths([string]$fromFolder,[string]$filter,[string]$printfile) {
  2. Get-ChildItem -Path $fromFolder -Recurse $filter | Select-Object -Property FullName > $printfile
  3. }

以上是关于创建一个文本文件,列出指向某个文件或通配符的所有路径。的主要内容,如果未能解决你的问题,请参考以下文章

如何在linux系统下建立组名sysadm操作命令

如何列出当前目录下,以install开头的所有文件

liunx查找以i开头的目录或文件名

ls 命令通配符

ls 命令通配符

linux如何查找以某个字母打头的文件或文件夹 比如,/etc目录下很多文件,我想列出所有以c开头的文件或文件