本帖最后由 ttszuo 于 2016-6-19 06:02 编辑
借用2楼的代码- @echo off
- cd /d "%~dp0"
- for /f "delims=" %%i in ('dir /b /a-d ^| findstr "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
- for /f "tokens=1,2 delims=^_" %%a in ('echo.%%~ni') do (
- echo.%%a|findstr /be "[0-9]*" >nul && move "%%~nxi" "%%a%%~xi"|| move "%%~nxi" "%%b%%~xi"
- )
- )
- pause
复制代码 也可以这个- @echo off
- cd /d "%~dp0"
- for /f "delims=" %%i in ('dir /b /a-d ^| findstr "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
- for /f "tokens=1,2 delims=^_" %%a in ('echo.%%~ni') do (
- if 1%%a gtr 99999999 (move "%%~nxi" "%%a%%~xi") else (move "%%~nxi" "%%b%%~xi")
- )
- )
- pause
复制代码 借用5楼的判断是否是数字- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- for /f "delims=" %%i in ('dir /b /a-d ^| findstr "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
- for /f "tokens=1,2 delims=^_" %%a in ('echo.%%~ni') do (
- set /a num=%%a
- if "!num!"=="%%a" (move "%%~nxi" "%%a%%~xi") else (move "%%~nxi" "%%b%%~xi")
- )
- )
- pause
复制代码
|