Board logo

标题: [文本处理] 批处理怎样在上万个文件里导出指定字符串? [打印本页]

作者: 126100    时间: 2019-6-27 10:38     标题: 批处理怎样在上万个文件里导出指定字符串?

{"BSSID":"0b:17:bf:aa:01:50","IpAddress":"10.97.27.110","P2p0Mac":"97:b3:f7:ed:09:fc","SSID":"PHICOMM_bad1f4","androidId":"2d66649f1a5259a1","batteryLevel":73,"btAddress":"50:2b:77:03:2c:03","btName":"2014501","buildAbi":"armeabi-v7a","buildAbi2":"armeabi","buildBoard":"roth","buildBrand":"Xiaomi","buildCodename":"REL","buildDescription":"HM2014501-user 7.1.2 NMF26Q fae5a1bd release-keys","buildDevice":"HM2014501","buildFingerprint":"Xiaomi/2014501/HM2014501:7.1.2/NMF26Q/fae5a1bd:user/release-keys","buildHardware":"qcom","buildHost":"sp-ci-01-desktop","buildId":"NMF26Q","buildIncremental":"fae5a1bd","buildManufacturer":"Xiaomi","buildModel":"2014501","buildName":"Xiaomi","buildProduct":"HM2014501","buildRadioVersion":"rusqpfccc","buildRelease":"7.1.2","buildSdk":"25","buildSerialno":"0b80dbeb","buildTags":"release-keys","buildType":"user","buildUser":"MarkBuild","buildUtc":1494391198147,"cellScan":["26666,191583233","22465,211652363","55232,161504425","22310,25291","16654,53"],"ci":161504425,"contacts":["奶奶,13300844303","姑妈,15505206633","外婆,13490537600","外公,18706374435","舅舅,18803713506","舅妈,15605678555","姨父,15205685027","姨娘,15701536582","亲爱的,13104695192","老弟,14700830894","老妹,13401386105","小明,15503165245","小李子,15007033282","井璎权,13201496049","Amy Fox,13207755936","闵同若,13200111167","吴恒思,13805410132","司徒许念,18808671868","Crystal Warren,18707355887","沈适,13206355554","邹游微,15904982253","韩信,15900176272","Elaine Morales,15804190230","诸葛雨魄,13507890425","李涂舒,18706446216","李校雄,18805753250","Jon Marshall,15703292865","蓝郡厚,13902037285","王恒建,15601437002","齐魁超,18804751374","Charlotte Foster,14700628628","吴虎,15201858990","吴彦,13304710999","杨经,13806175764","Gail Miller,13605917498","诸为翼,15607138938","贝乐杏,15500461988","张雍,18602845361","Janet Gomez,15500124586","云联康,13801122856","李演,15803298129","李岭谷,18801575981","Donald Sanders,18701445924","鲁情凇,14707993213","方默信,18604072696"],"cpuName":"MT6582","densityDpi":320,"deviceId":"860151286932132","deviceSvn":"53","displayId":"HM2014501-user 7.1.2 NMF26Q fae5a1bd release-keys","droid62":"{258\u003d860151286932132\u0026 256\u003dA86015128693213\u0026 259\u003dXiaomi2014501: swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt: ARMv7 Processor rev 2 (v7l): 7: MT6582: 0000000000000000}","extraInfo":"ctlte","filePath":"/storage/emulated/0/.money/backup/20180508/13199407469_wxid_6pswdo8216t722_20180508.aw","height":0,"hidePkgs":[],"hmNotes":"","hookPkgs":[],"id":693,"lac":55232,"latitude":31.0023387,"line1Number":"13199407469","longitude":119.9684878,"macAddress":"8f:77:a5:6f:c9:e4","memAvailable":24045939,"memFree":72137820,"memTotal":96183759,"mnc":"01","networkClass":3,"networkCountryIso":"cn","networkOperator":"46001","networkOperatorName":"中国联通","networkType":13,"networkTypeName":"LTE","phoneType":1,"rgAndroid":"23","rgAreaode":"86","rgConNames":["喔喔","Vfdw Abpob"],"rgConsize":"0","rgCountry":"中国","rgDevice":"比特币","rgIp":"124.160.214.215","rgLastLogin":1531328913754,"rgLocation":"浙江省杭州市 联通","rgNetType":"切换飞行模式","rgOrPhone":"13199407469","rgPhoneNo":"13199407469","rgServer":"飞行模式切换","rgTime":1525792679667,"rgVcode":"AW(接码/发码)","rgVersion":"2.1.5","rgWxEmail":"未绑定","rgWxError":"","rgWxId":"wxid_6pswdo8216t722","rgWxName":"喔喔","rgWxNo":"wxid_6pswdo8216t722","rgWxPasswd":"hihihi762903","rgWxQQ":"未绑定","rgWxStatus":"存活","rgWxWindows":"否","serialno":"0b80dbeb","simCountryIso":"cn","simOperator":"46001","simOperatorName":"中国联通","simSerialNumber":"8986094186873846211","simState":5,"subscriberId":"460013126117265","type":0,"typeName":"MOBILE","width":0,"wifiScan":["MERCURY_d6b991,34:ce:00:74:4d:24,[WPA2-PSK-CCMP][WPS][ESS],-55,2427,1445737211","TP-LINK_a65559,ec:82:63:41:f4:78,[WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS],-62,2427,344020914","TP-LINK_d22105,68:9f:f0:f3:13:00,[WPA-PSK-CCMP][WPA2-PSK-CCMP][WPS][ESS],-89,2412,283533012","Netcore_7cba87,04:5f:a7:3e:0c:1c,[WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS],-75,2432,498377594","Tenda_440ffe,50:3a:a0:16:96:ba,[WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS],-76,2412,386784201"]}

有上万个文件  每个文件里面有一段这样的代码如何批量处理导出呢。               我只需要带颜色的导出,比如wxid_6pswdo8216t722----hihihi762903
作者: zaqmlp    时间: 2019-6-27 12:38

本帖最后由 zaqmlp 于 2019-6-27 13:57 编辑
  1. @echo off
  2. set info=互助互利,支付宝扫码头像,感谢赞助
  3. rem 有问题,可加QQ956535081及时沟通
  4. title %info%
  5. cd /d "%~dp0"
  6. powershell -NoProfile -ExecutionPolicy bypass ^
  7.     [System.Collections.ArrayList]$s=@();^
  8.     $files=@(dir^|?{(@('.txt') -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});^
  9.     for($i=0;$i -lt $files.count;$i++){^
  10.         $text=[IO.File]::ReadAllText($files[$i].FullName, [Text.Encoding]::Default);^
  11.         $m=[regex]::matches($text,'\"rgWxNo\":\"([^^\""]+)\"[\s\S].?\"rgWxPasswd\":\"([^^\""]+)\"');^
  12.         foreach($item in $m){^
  13.             $line=$item.groups[1].value+('-'*4)+$item.groups[2].value;^
  14.             [void]$s.add($line);^
  15.         };^
  16.     };^
  17.     [IO.File]::WriteAllLines('结果.log', $s, [Text.Encoding]::Default);^
  18.     write-host '%info%' -ForegroundColor green;
  19. pause
复制代码

作者: 126100    时间: 2019-6-27 14:34

回复 2# zaqmlp


    技术牛逼~~~真鸡儿太牛了。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2