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
6
  • 1
    ren ???55.png ??? See superuser.com/q/475874/109090 for an explanation
    – dbenham
    Sep 1, 2014 at 11:24
  • 1
    @dbenham The command should be ren ???55.png ???.png The only caveat is that it only works if the file name length is always 5 (3+2). For a more generic solution, a batch script is the only way to go, I guess.
    – and31415
    Sep 1, 2014 at 11:29
  • well I have some different file name sizes. like wioqetr55.png and jsad55.png
    – tato469
    Sep 1, 2014 at 11:29
  • possible duplicate of Batch Renaming Automation *_2.* TO *.*
    – and31415
    Sep 1, 2014 at 11:31
  • the soultion gived by @and31415 worked for me :)
    – tato469
    Sep 1, 2014 at 11:35

1 Answer 1

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
)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .