[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. cd /d "%~dp0"
  3. set rootdir=\\192.168.11.123\pool\test123\p01-1
  4. set outfile="搜索结果.txt"
  5. :loop
  6. set dtm=
  7. set str=
  8. set /p dtm=输入时间:
  9. if not defined dtm goto end
  10. set /p str=输入搜索字符串:
  11. if not defined str goto end
  12. findstr /ilbc:"%dtm%" "%rootdir%\*.txt"|find /i /c "%str%">>%outfile%
  13. goto loop
  14. :end
  15. exit /b
复制代码
微信:flashercs
QQ:49908356

TOP

  1. <#*,:&cls
  2. @echo off
  3. cd /d "%~dp0"
  4. powershell -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~f0\" -ReadCount 0 | Out-String)))"
  5. pause
  6. exit /b
  7. #>
  8. # 功能:按时间搜索指定目录下txt文档中的字符串,按ctrl+c退出
  9. $rootdir = "\\192.168.11.123\pool\test123\p01-1"
  10. $outfile = "搜索结果.log"
  11. $arrPso = foreach ($arrLines in Get-Content -ReadCount 0 -Path "$rootdir\*.txt" -Filter *.txt -ErrorAction SilentlyContinue) {
  12.   foreach ($line in $arrLines) {
  13.     $sDate, $sTime, $sText = $line -split '\s+', 3
  14.     ($pso = New-Object psobject -Property @{
  15.       Date = [datetime]"$sDate $sTime"
  16.       Text = $sText
  17.     })
  18.   }
  19. }
  20. $Host.UI.RawUI.WindowTitle = "按 Ctrl+C 退出"
  21. # exit
  22. while ($true) {
  23.   do {
  24.     $startTime = $null
  25.     $startTime = (Read-Host -Prompt 请输入起始时间) -as [datetime]
  26.   } while ($null -eq $startTime)
  27.   do {
  28.     $endTime = $null
  29.     $endTime = (Read-Host -Prompt 请输入结束时间) -as [datetime]
  30.   } while ($null -eq $endTime)
  31.   $strSearch = Read-Host -Prompt 请输入查找字符串
  32.   $alResult = $null
  33.   $arrPso | Where-Object { $_.Date -ge $startTime -and $_.Date -lt $endTime -and $_.Text.Contains($strSearch) } -OutVariable alResult | Format-Table -AutoSize
  34.   "$startTime $endTime $strSearch $($alResult.Count)" | Add-Content -LiteralPath $outfile
  35. }
复制代码
微信:flashercs
QQ:49908356

TOP

返回列表