仅在命令行中列出带有路径和文件大小的文件 [英] List files with path and file size only in Command Line

查看:40
本文介绍了仅在命令行中列出带有路径和文件大小的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 命令行(或 PowerShell).

如何递归地列出所有文件,包括完整路径和文件大小,但没有其他任何内容并导出到 .txt 文件.最好是代码适用于我使用命令行所在的任何当前目录(因此不需要手动输入目标目录).

How can I list all files, recursively, with full path and filesize, but without anything else and export to a .txt file. Much preferably a code that works for whichever current directory I am in with the Command Line (so does not require manual entering of the target directory).

这些都不提供路径\文件名和文件大小:

None of these provides path\filename and filesize only:

dir /s > filelist.txt
dir /s/b > filelist.txt
dir /s/o:-d > filelist.txt

所需的输出(完整路径\file.ext 文件大小):

c:\aaa\file.ext 7755777    
c:\aaa\bbb\1.txt 897667
c:\aaa\bbb\2.ext 67788990
c:\aaa\bbb\nnn\a.xls 99879000

推荐答案

Get-ChildItem -Recurse | select FullName,Length | Format-Table -HideTableHeaders | Out-File filelist.txt

这篇关于仅在命令行中列出带有路径和文件大小的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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