@echo off setlocal enabledelayedexpansion set /a ct=0 for /f "tokens=* delims-" %%a in ('dir file*.txt /a:-d /o:d') do ( set /a ct+=1 set new=%%a :"4" is based on "file", if length is diff. substitute actual length set new=!new:~0,4! :foll two lines are for testing. examine temp.bat to see if... echo ren %%a new!ct! echo ren %%a new!ct! >> temp.bat pause :ren %%a new!ct!)
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this
site. Computing.Net and Purch hereby disclaim all responsibility
and liability for the content of Computing.Net and its accuracy.