Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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,
AJR3

This will get you started. You'll get errors if, for instance, you have:
file1
file2It 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 :sub1 for /L %%i in (0 1 9) do ( if "!str!" neq "" ( set str=!str:%%i=! ) ) goto :eof
=====================================
Helping others achieve escape felicityM2

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |