So i'm trying to get a script to change file names with in a folder. However, i need the file names to ascend within 001 to 000999. Ever time a file is added a number is assigned to it within the numbers of 001 to 000999. If that makes sense.
Asked
Active
Viewed 53 times
-4
-
Did you try something ? – SachaDee Feb 15 '16 at 21:00
-
3Your question is not clear. If `001` have _two_ zeros before the number and `000999` have _three_ zeros before the number, what is the rule to choose 2 or 3 zeros before the number? – Aacini Feb 15 '16 at 21:14
1 Answers
0
If this is done in one run here is a way. But this will count from 000001 to 999999 :
@Echo off
setlocal enabledelayedexpansion
set /a $c=1
for %%a in (*.*) do (
set "$Newname=00000!$c!"
echo ren "%%a" "!$Newname:~-6!%%~xa"
set /a $c+=1
)
Remove the echo
if that's what you need.

SachaDee
- 9,245
- 3
- 23
- 33
-
It is simpler this way: `set $c=1000001` and inside the for: `echo ren "%%a" "!$c:~1!%%~xa"` & `set /a $c+=1` – Aacini Feb 15 '16 at 21:24