0

I have some files in my folder like:

asd55.png
qwe55.png
zxc55.png

I want to remove the 55 and get the result:

asd.png
qwe.png
zxc.png

I tried with:

ren *55.png *.png

but doesnt work.

NOTE:

I have different name sizes like:

asd55.png
qwerty55.png
tato469
  • 155
  • 1
  • 7

1 Answers1

1
ren ???55.png ???.png

See How does the Windows RENAME command interpret wildcards? for an explanation

If the number of characters before 55 varies, then you will probably want to use a batch script. (Could be done with a fairly complicated one liner on the command line, but not worth it)

@echo off
setlocal enableDelayedExpansion
for /f "delims=" %%F in ('dir /a-d ?*55.png') do (
  set "name=%%~nF"
  ren "%%F" "!name:~0,-2!%%~xF"
)

If any file name might contain !, then delayed expansion must be toggled on and off within the loop.

@echo off
setlocal disableDelayedExpansion
for /f "delims=" %%F in ('dir /a-d ?*55.png') do (
  set "name=%%~nF"
  set "ext=%%~xF"
  setlocal enableDelayedExpansion
  ren "!name!!ext!" "!name:~0,-2!!ext!"
  endlocal
)
dbenham
  • 11,794