Removing Numbers from Filename

October 12, 2009 at 20:51:37
Specs: Windows Vista, Core2Quad Q6700 4GB RAM
Hi, I am wondering how I might go about removing all numbers from all the files in a directory (and how I might exclude certain files from this rename which are named in a exclude.txt in the same directory).

Thank You,

See More: Removing Numbers from Filename

Report •

October 13, 2009 at 15:29:30
This will get you started. You'll get errors if, for instance, you have:


It will rename the first to file and error on the second.

It is smart enough not to rename 123.doc to .doc, which you probably don't want.


@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('dir/b') do (
find /i "%%a" < exclude.txt > nul

if errorlevel 1 (
  set str=%%~Na
  call :sub1
if "!str!" neq "" (
  echo ren "%%a" "!str!%%~Xa"
goto :eof

  for /L %%i in (0 1 9) do (
    if "!str!" neq "" (
      set str=!str:%%i=!
goto :eof

Helping others achieve escape felicity


Report •
Related Solutions

Ask Question