刚学搞得一个功能, 计算文件名长度后, 重命名文件- :bigen
- cls
-
- set /p a=inputLOT ID:
-
-
-
- for /l %%a in (0,1,9999) do (
- set /a b+=1
- if not "!a:~%%a,1!"=="" (
- set c=!b!
- )
- )
- set /p=%c%
-
- if %c% equ 9 goto a
- if %c% equ 10 goto b
- goto error
-
- :error
- color 4f
- echo.
- echo 错误,输入批号有误请重新输入
- pause>nul 2>nul
- goto bigen
-
- :a
- @echo off
- setlocal enabledelayedexpansion
- set s=map
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.txt') do (
- set "line=%%i"
- echo "%%i" | findstr %s% && ren "%%i" "!line:~0,12!_CP map.txt" || ren "%%i" "!line:~0,12!_Counter.txt"
- )
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.plf') do (
- set "line=%%i"
- ren "%%i" "!line:~0,12!.plf"
- )
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.xls') do (
- set "line=%%i"
- echo "%%i" | findstr %s% && del /s /q /f *map.xls|| ren "%%i" "!line:~0,12!.xls"
- )
- pause>nul 2>nul
- exit
-
- :b
- color 2f
- cls
- @echo off
- setlocal enabledelayedexpansion
- set s=map
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.txt') do (
- set "line=%%i"
- echo "%%i" | findstr %s% && ren "%%i" "!line:~0,13!_CP map.txt" || ren "%%i" "!line:~0,13!_Counter.txt"
- )
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.plf') do (
- set "line=%%i"
- ren "%%i" "!line:~0,13!.plf"
- )
- for /f "tokens=* delims=" %%i in ('dir /b /a-d *.xls') do (
- set "line=%%i"
- echo "%%i" | findstr %s% && del /s /q /f *map.xls|| ren "%%i" "!line:~0,13!.xls"
- )
- pause>nul 2>nul
- exit
复制代码
|