Example file list:
- 1.jpg
- 2.jpg
- 3.jpg
- 22.jpg
easy cycle for iterating the list
for /r %j in (*.jpg) do @echo %~nxj
The gives the following result:
1
2
22
3
How can i order the results consecutively, like below?
1
2
3
22
thanks everyone
Example file list:
easy cycle for iterating the list
for /r %j in (*.jpg) do @echo %~nxj
The gives the following result:
1
2
22
3
How can i order the results consecutively, like below?
1
2
3
22
thanks everyone
I have just made this for you it seems that your way would of worked but there is a simpler way of doing it.
@echo off
del /q /s /f "%temp%\TEMP.tmp">nul
dir /b *.* >> %temp%\TEMP.tmp
SetLocal EnableDelayedExpansion
for /f "delims=" %%x in ('type %temp%\TEMP.tmp') do (
set "Var=%%x"
ECHO !Var!
)
pause
Put the bat file in the same dir as the pictures.
@ECHO Off
SETLOCAL ENABLEDELAYEDEXPANSION
SET "sourcedir=U:\sourcedir"
(
FOR /f %%a IN ('dir /b /a-d "%sourcedir%\*.jpg" ') DO (
SET /a seq=1000000000+%%~na
ECHO !seq!)
)>"%temp%\tempfile"
FOR /f %%a IN ('sort "%temp%\tempfile"') DO (
SET /a seq=%%a-1000000000
ECHO !seq!.jpg)
)
GOTO :EOF
This should work for you - of course, you'd need to set your own sourcedir
, the temp filename is up to you, it's not cleaned up and it will only work with pure-numeric filenames without leading zeroes <1000000000. The .jpg
extension is assumed.