[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
适用于数量不是太多,以免影响速度。若10万以上可以不用。须换NET版才能提速。
POWERSHELL 运行。
  1. $Lists = New-Object System.Text.StringBuilder;
  2. $files = ls 'D:\1\' -r | ?{$_.Directory};
  3. $m = $files.Count.tostring().Length;
  4. Foreach ( $i in $files )
  5. {
  6. $index++;
  7. $ref = $i.Length;
  8. switch ( $ref.tostring().length )
  9. {
  10. {$_ -le 3} { $length = "{0:0.000} Byte" -f ($ref);break}
  11. {$_ -le 6} { $length = "{0:0.000} KB" -f ($ref/1KB);break}
  12. {$_ -le 9} { $length = "{0:0.000} MB" -f ($ref/1MB);break}
  13. $_ { $length = "{0:0.000} GB" -f ($ref/1GB)}
  14. }
  15. $n = '[' + $index.tostring().padleft($m,' ') + ']';
  16. [void]$Lists.AppendLine($n+' '+$i.name);
  17. [void]$Lists.AppendLine(' '*($m+3)+$length);
  18. [void]$Lists.AppendLine(' '*($m+3)+$i.LastWriteTime);
  19. [void]$Lists.AppendLine(' '*($m+3)+$i.FullName);
  20. [void]$Lists.AppendLine('');
  21. }
  22. [IO.File]::WriteAllLines("$pwd\输出.log",$Lists,[text.encoding]::Default);
复制代码

TOP

返回列表