by bru » Tue Jan 21, 2020 10:22 am
Nope, brc doesnt make it avail as a shell/env variable.
There's different ways to work around it, depending on your circumstance.
If you always rename all-files-with-an-extension, use something like:
@echo off
CD "C:\YourFTPFolder\"
::
:: If no renames, Set counter=1 (1st as file, then variable)
IF not exist "00000001" IF not exist "count" Echo.1>count
For /f %%A IN (count) DO set next=%%A
::
:: Resume naming (files with .ext)
Brc32 /IgnoreFileX /Pattern:"*.*" /RemoveName /AutoNumber:%next%:1:P::10:8 /execute
Ren count count.brc
::
:: Grab HighestRename# (Reverse sort NamesWithout.ext) then Goto Save
For /f %%B IN ('dir/b/a-d/o-n *.') DO Set high=%%B&&Goto Save
::
:Save counter (Strip Leading-0s, Add1, SaveToFile)
For /f "delims=0 tokens=*" %%C IN ("%high%") DO cmd /c Set /a next="%%C+1">count.brc
Ren count.brc count
::
:: Review Renames (delete this section if not desired)
echo.Done, press any key to exit.
pause>nul
That works for renaming all-files-with-an-extension.
With some of your files already numbered, a 1st-time run tries/fails to rename as 00000001, etc.
However, it also creates a proper resume-count file for all subsequent runs.
You could simplify it by keeping the count-file in another folder (versus renaming it back-and-forth).
Doubt I have all the details for your particular circumstance.