Windows:如何以大小和上次访问日期递归列出文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13345066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Windows : How to list files recursively with size and last access date?
提问by Baine Wedlock
I need a simple way to create a list of all files in a certain folder. (recursively)
我需要一种简单的方法来创建某个文件夹中所有文件的列表。(递归)
Each file must be in a single line. I also need the file size and the last access date in the same line, separated by a special character.
每个文件必须在一行中。我还需要在同一行中的文件大小和上次访问日期,用特殊字符分隔。
The output (textfile) should look like this:
输出(文本文件)应如下所示:
c:\folder\file1.txt|400|2012-11-12 15:23:08
c:\folder\file2.txt|200|2012-11-12 15:23:08
c:\folder\file3.txt|100|2012-11-12 15:23:08
c:\folder\sub folder\file4.txt|500|2012-11-12 15:23:08
'Dir' seems not to be an option, because the German Special characters get messed up that way. (??ü?)
'Dir' 似乎不是一个选项,因为德语特殊字符会以这种方式搞砸。(??ü?)
Powershell handles the special characters well, but I couldn't make it so that the information for one file ends up in a single line:
Powershell 可以很好地处理特殊字符,但我无法做到让一个文件的信息以一行结尾:
get-childitem D:\temp -rec | where {!$_.PSIsContainer} | foreach-object -process {$_.FullName, $_.LastWriteTime, $_.Length}
回答by CB.
try this:
尝试这个:
get-childitem D:\temp -rec | where {!$_.PSIsContainer} |
select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -delimiter '|' -path file.csv