Solved Windows Batch to rename only file names with SSR0xxxx.txt

June 26, 2014 at 15:14:40
Specs: Windows 64
Hi All,
Please help me to write a batch file

Windows Batch to rename only file names with SSR0xxxx.txt to SSR0xxxx.csv

there are plenty of files to be renamed are SSR01000.txt
SSR01001.txt
SSR01999.txt
SSR09999.txt

I tried the below but picking many other unwanted files SSR09999_1.txt, SSR09999_copy.txt ...etc
for /r %x in (SSR0*.txt) do ren "%x" *.csv

Please help me on how to rename those files with 4 digits only after the static file name SSR0

Thanks in advance Gurus


See More: Windows Batch to rename only file names with SSR0xxxx.txt

Report •

#1
June 26, 2014 at 20:45:47
✔ Best Answer
Simplest method offhand:
for /L %%a in (1000 1 9999) do ren SSR0%%a.txt SSR0%%a.csv 2>nul
::==== end

this excludes anything but the four digits between 1000 and 9999 to qualify for your files to be renamed. (Also excluding 0001 - 0999)

message edited by nbrane


Report •
Related Solutions


Ask Question