@echo off
set "self=%~nx0"
rename 1.txt aabb____1.txt
rename 2.log aabb____2.log
for /f "delims=" %%i in ('dir /b /a-d *aabb*.*') do rename "%%i" "aabb____%%i"
for %%i in (*) do (
set str=%%i
setlocal enabledelayedexpansion
if "!str:~0,4!" neq "aabb" (
if "!str!" neq "!self!" (
del "!str!"
)
)
endlocal
)
for %%i in (*) do (
set str=%%i
setlocal enabledelayedexpansion
if "!str!" neq "!self!" rename "!str!" "!str:~7!"
endlocal
)