[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
可能是编码的问题造成的。
参考一下这个帖子  http://www.bathome.net/viewthread.php?tid=66267
bat小白,请多指教!谢谢!

TOP

本帖最后由 77七 于 2023-6-6 23:45 编辑

回复 3# 暴牙弟


http://www.bathome.net/redirect.php?goto=findpost&;ptid=66267&pid=269641
然后使用 find /i
bat小白,请多指教!谢谢!

TOP

回复 5# 暴牙弟


  
  1. @echo off
  2. chcp 65001
  3. Setlocal enabledelayedexpansion
  4. FOR /D %%a IN (*) DO (
  5. echo %%~fa
  6. cd /d %%~fa
  7. for /r %%i in (*.jpg) do (
  8. convert.exe -crop 2470x180+20+193 "%%i" "tmp.jpg"
  9. tesseract "tmp.jpg" "tmp" -l chi_sim
  10. find /i "银行" "tmp.txt" >nul
  11. if errorlevel 1 (convert -crop 555x80+505+370 "%%i" "tmp2.jpg"
  12. tesseract.exe "tmp2.jpg" "tmp2" -l chi_sim
  13. ping -n 2 127.0.0.1>nul
  14. set /P file=<"tmp2.txt"
  15. mkdir !file!
  16. move "%%i" !file!
  17. ) else ( set /P file=<"tmp2.txt"
  18. move "%%i" !file!)
  19. )
  20. )
  21. pause
复制代码
不用改成goto 吧,这样不行吗?
bat小白,请多指教!谢谢!

TOP

回复 7# 暴牙弟


   errorlevel 1是失败,0是成功吧,没有银行,应该执行失败,会执行 errorlevel 1那段,不是else 那段。先试试行不行。
goto 的标签不能写在括号里面。
如果想跳回去可以使用call,你可能把call和goto 搞混淆了。
for /r 可能有点问题,可以改成for /f "delims=" %%x in ('dir /b /s /a-d *.jpg') 这种形势
bat小白,请多指教!谢谢!

TOP

回复 9# 暴牙弟


  
  1. @echo off
  2. chcp 65001
  3. Setlocal enabledelayedexpansion
  4. FOR /D %%a IN (*) DO (
  5. pushd "%%a"
  6. for /f "delims=" %%i in ('dir /b /s /a-d *.jpg') do (
  7. echo 正在处理:%%i
  8. convert.exe -crop 2470x180+20+193 "%%i" "tmp.jpg"
  9. tesseract "tmp.jpg" "tmp" -l chi_sim
  10. find /i "银行" "tmp.txt" >nul
  11. if errorlevel 1 (
  12. echo 正在处理:%%i errorlevel=1
  13. set /P file=<"tmp2.txt"
  14. move "%%i" "!file!"
  15. ) else (
  16. echo 正在处理:%%i errorlevel=0
  17. del "tmp2.txt" 2>nul
  18. convert -crop 555x80+505+370 "%%i" "tmp2.jpg"
  19. tesseract.exe "tmp2.jpg" "tmp2" -l chi_sim
  20. ping -n 2 127.0.0.1 >nul
  21. set /P file=<"tmp2.txt"
  22. mkdir "!file!"
  23. move "%%i" "!file!"
  24. )
  25. del "tmp.txt";"tmp.jpg";"tmp2.jpg" 2>nul
  26. )
  27. popd
  28. )
  29. pause
复制代码
我觉得没有必要用call,先理清逻辑和检查错误。find的问题不知道是否确定已解决?
如果不行,提供个测试文件吧。
bat小白,请多指教!谢谢!

TOP

返回列表