As for the batch file to make unique saving without using dates?

Current code:
set dir1=C:\TEST\ScanTo\
set strTime=_%Date%_%Time%
set strTime=%strTime::=-%
set strTime=%strTime:,=-%
set strTime=%strTime:/=-%
%SYSTEMDRIVE%


Want to keep:

скан_1
скан_2
скан_3
...

Let's say I deleted these scans and the counter must start again, i.e. there should be a check in the beginning of the code
The variable strTime is essentially a counter with a check for uniqueness
June 10th 19 at 15:31
3 answers
June 10th 19 at 15:33
Create a file - for example
count.txt
and there store an intermediate value for the increment
Removed the scans and have to start over - delete the file.
June 10th 19 at 15:35
if the file names differ only in the number and is a constant number of digits, ie not скан_1 and скан_000001,скан_000002,скан_000003, then you can:
@echo off
for /f %%a in ('dir /b /on "scan*.jpg"') do set tmp=%%a&goto lev1
:lev1
echo %tmp%
set /a next_file_num=%tmp:~-10,6% +1
set next_file_num_str=000000%next_file_num%
set next_file_num_str=%next_file_num_str:~-6%
set next_file_name=скан_%next_file_num_str%.jpg
echo %next_file_name%
June 10th 19 at 15:37
Your "AC" value - the number of files in the folder.
@for /F %%a IN ('attrib.exe ./*.* ^|find /c /v ""') DO @set result=%%~a
@echo %result%

next, use the result variable as you wish

Find more questions by tags cmd/bat