找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 17021|回复: 5

统计,当前文件及子文件(zip)内TXT文本数量(去重)

  [复制链接]
发表于 2019-12-3 22:08:07 | 显示全部楼层 |阅读模式
本帖最后由 qq110110 于 2019-12-7 19:40 编辑

具体报酬:3元
支付方式:支付宝转账(提供二维码,或者手机号)
联系方式:手机
有效期限:2019/12/10
需求描述:

统计当前文件夹及其子文件夹(zip文件)内
TXT文本(去除重复后)的数量。         

1楼,能统计TXT去重个数。剩下那句话不知道加在哪。
2楼,window可以用。window7提示找不到。
发表于 2019-12-3 22:31:33 | 显示全部楼层
  1. @echo off
  2. set info=互助互利,支付宝扫码头像,感谢打赏
  3. rem 有问题,可加QQ956535081及时沟通
  4. title %info%
  5. powershell -NoProfile -ExecutionPolicy bypass "(dir -recurse|?{('.txt' -eq $_.Extension) -and ($_ -is [System.IO.FileInfo])}|group {$_.Name.toLower()}).count;"
  6. echo;%info%
  7. pause
复制代码
发表于 2019-12-3 22:40:13 | 显示全部楼层
  1. ('.zip' -eq $_.Extension)
复制代码
发表于 2019-12-3 23:01:06 | 显示全部楼层
  1. <#*,:&cls
  2. @echo off
  3. pushd "%~dp0"
  4. Powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath "%~0" -ReadCount 0 | Out-String ))) "
  5. popd
  6. pause
  7. exit /b
  8. #>
  9. Add-Type -AssemblyName System.IO.Compression.FileSystem
  10. # 目录列表,绝对路径或相对路径
  11. Get-ChildItem -Path *.txt -Recurse | Foreach-Object {
  12.   if (!$_.PSIsContainer) {
  13.     $_.PSChildName
  14.   }
  15. } -OutVariable txtlist | Out-Null
  16. Get-ChildItem -Path *.zip -Recurse | ForEach-Object {
  17.   if (!$_.PSIsContainer) {
  18.     try {
  19.       $archive = [System.IO.Compression.ZipFile]::Open($_.FullName, 'Read')
  20.       $archive.Entries | ForEach-Object {
  21.         if ($_.Name -like '*.txt') {
  22.           $_.Name
  23.         }
  24.       }
  25.     } finally {
  26.       $archive.Dispose()
  27.     }
  28.   }
  29. } -OutVariable +txtlist | Out-Null
  30. $txtlist | Group-Object -OutVariable groupinfos
  31. "`n文本文件数量: " + $groupinfos.Count
复制代码
 楼主| 发表于 2019-12-3 23:16:59 | 显示全部楼层
回复 3# zaqmlp


    这一句要加到哪里啊?
 楼主| 发表于 2019-12-4 18:35:36 | 显示全部楼层
回复 4# flashercs


    widnow10可以,window7提示无法新增类型,找不到组件,不可再null的运算上呼叫方法
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 06:47 , Processed in 0.018219 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表