[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 Nsqs 于 2017-1-18 09:10 编辑

方法1
  1. @echo off&setlocal enabledelayedexpansion
  2. set "ff=收集"
  3. md "%ff%" 2>nul
  4. for %%i in ("*.txt")do (set f=%%i
  5. (for /f "tokens=1,2 delims=:#" %%1 in ('findstr /n "^[\u4e00-\u9fff0]*\ #" "%%i"')do (
  6. set b=%%2
  7. set /a s=%%1
  8. if "%%2"=="视频 " (set /a c1+=1
  9. call echo %%2#%%c1%%
  10. call:视频&echo;
  11. )
  12. if "%%2"=="音频 " (set /a c2+=1
  13. call echo %%2#%%c2%%
  14. call:音频&echo;
  15. )
  16. if "%%2"=="菜单 " (set /a c3+=1
  17. call echo %%2#%%c3%%
  18. call:菜单&echo;
  19. )
  20. ))>%ff%\%ff%_%%~ni.txt
  21. )
  22. exit
  23. :视频
  24. for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
  25. set a=%%1
  26. call set a=%%a: =%%
  27. for %%3 in (文件格式 画面高度 扫描方式)do (
  28. if "!a!"=="%%3" echo %%1:%%2&set /a z+=1
  29. if !z! geq 3 set z=0&goto :eof
  30. )
  31. )
  32. goto :eof
  33. :音频
  34. for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
  35. set a=%%1
  36. call set a=%%a: =%%
  37. for %%3 in (文件格式 采样率)do (
  38. if "!a!"=="%%3" echo %%1:%%2&set /a z+=1
  39. if !z! geq 2 set z=0&goto :eof
  40. )
  41. )
  42. goto :eof
  43. :菜单
  44. for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
  45. set a=%%1
  46. call set a=%%a: =%%
  47. if "!a!"=="服务名" echo %%1:%%2&goto :eof
  48. )
  49. goto :eof
复制代码
方法2
  1. @echo off&setlocal enabledelayedexpansion
  2. set "ff=收集"
  3. md "%ff%" 2>nul
  4. set "cl1=视频"
  5. set "cl2=音频"
  6. set "cl3=菜单"
  7. set "ss1=文件格式 画面高度 扫描方式"
  8. set "ss2=文件格式 采样率"
  9. set "ss3=服务名"
  10. for /l %%1 in (1 1 3)do call set "cl%%1=!cl%%1! "
  11. set "m=%cl1%
  12. set /a n1=3,n2=2,n3=1
  13. for %%i in ("*.txt")do (set f=%%i&set /a c=1,x=1
  14. (for /f "tokens=1,2 delims=:#" %%1 in ('findstr /n "^[\u4e00-\u9fff0]*\ #" "%%i"')do (
  15. set b=%%2
  16. set /a s=%%1
  17. call:d&echo;
  18. ))>%ff%\%ff%_%%~ni.txt
  19. )
  20. exit
  21. :d
  22. set /a z+=1
  23. call echo %%b%%#%%z%%
  24. call set ss=%%ss!x!%%
  25. call set n=%%n!x!%%
  26. if !z! geq 4 (
  27. set /a x+=1,z=0
  28. call set m=!cl%%x%%!
  29. )
  30. for /f "tokens=1,2 delims=:#" %%1 in ('more +%s%^<%f%')do (
  31. set a=%%1
  32. call set a=%%a: =%%
  33. for %%3 in (%ss%)do (
  34. if "!a!"=="%%3" echo %%1:%%2&set /a z1+=1
  35. if !z1! geq %n% set z1=0&goto :eof
  36. )
  37. )
复制代码
两个方法效率一样的

TOP

本帖最后由 Nsqs 于 2017-1-18 09:23 编辑

回复 2# kouyuhedou
楼主口气真大,没谁没事无偿求着给你写吧,excel部分就不写了自己可以百度

TOP

返回列表