批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖
第四课结束,继续感谢大佬

TOP

回复 10# xiong8707
  1. @echo off
  2. @set /p input=0,1,2
  3. if "%input%"=="0" goto A
  4. if "%input%"=="1" goto B
  5. if "%input%"=="2" goto C
  6. pause>nul
  7. exit
  8. :A
  9. md test1
  10. pause
  11. exit
  12. :B
  13. md test2
  14. pause
  15. exit
  16. :C
  17. md test3
  18. pause
  19. exit
复制代码
输入0,1,2 分别创建文件夹test1,test2,test3

TOP

回复 14# nanoking


    set no=:
这个设置是什么意思啊?

TOP

回复 14# nanoking


    set "no=%no:"=%"

这一句什么意思?

TOP

if not exist x (md x)
如果不存在x 创建一个名为x的文件夹

TOP

刚学搞得一个功能, 计算文件名长度后, 重命名文件
  1. :bigen
  2. cls
  3. set /p a=inputLOT ID:
  4. for /l %%a in (0,1,9999) do (
  5.     set /a b+=1
  6.     if not "!a:~%%a,1!"=="" (
  7.         set c=!b!
  8.     )
  9. )
  10. set /p=%c%
  11. if %c% equ 9 goto a
  12. if %c% equ 10 goto b
  13. goto error
  14. :error
  15. color 4f
  16. echo.
  17. echo  错误,输入批号有误请重新输入
  18. pause>nul 2>nul
  19. goto bigen
  20. :a
  21. @echo off
  22. setlocal enabledelayedexpansion
  23. set s=map
  24. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.txt') do (
  25. set "line=%%i"
  26. echo "%%i" | findstr %s% && ren "%%i" "!line:~0,12!_CP map.txt" || ren "%%i" "!line:~0,12!_Counter.txt"
  27. )
  28. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.plf') do (
  29. set "line=%%i"
  30. ren "%%i" "!line:~0,12!.plf"
  31. )
  32. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.xls') do (
  33. set "line=%%i"
  34. echo "%%i" | findstr %s% && del /s /q /f *map.xls|| ren "%%i" "!line:~0,12!.xls"
  35. )
  36. pause>nul 2>nul
  37. exit
  38. :b
  39. color 2f
  40. cls
  41. @echo off
  42. setlocal enabledelayedexpansion
  43. set s=map
  44. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.txt') do (
  45. set "line=%%i"
  46. echo "%%i" | findstr %s% && ren "%%i" "!line:~0,13!_CP map.txt" || ren "%%i" "!line:~0,13!_Counter.txt"
  47. )
  48. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.plf') do (
  49. set "line=%%i"
  50. ren "%%i" "!line:~0,13!.plf"
  51. )
  52. for /f "tokens=* delims=" %%i in ('dir /b /a-d *.xls') do (
  53. set "line=%%i"
  54. echo "%%i" | findstr %s% && del /s /q /f *map.xls|| ren "%%i" "!line:~0,13!.xls"
  55. )
  56. pause>nul 2>nul
  57. exit
复制代码

TOP

返回列表