- @echo off
- set "keyWord=ABC"
- for /f "delims=" %%i in ('findstr /i /s /m /c:"%keyWord%" *.txt') do (
- set "name=%%~ni"
- setlocal enabledelayedexpansion
- set "newName=!name!%%~xi"
- md "D:\!keyWord!" 2>nul
- for /l %%j in (1 1 100) do (
- if exist "D:\!keyWord!\!newName!" set "newName=!name!_%%j%%~xi"
- )
- for %%j in ("D:\!keyWord!\!newName!") do (
- endlocal & move "%%i" "%%~fj"
- )
- )
- pause
复制代码
|