Hello you helped me on another topic with this:
Hello I want to order a serie of files I have in c:\data
and so on any number of files.
This files could be hundred and there are names that doesn't exist in sequence like file003.pdf, file005.pdf, etc. Now in command prompt what script could be to order in sequence all that files and the numbers of the fies doesn't exist will be taken for next files in sequence for example file003.pdf doesn't exist then file004.pdf will take the name of file003.pdf in our example file007.pdf will take the name of file004.pdf, file009.pdf will take the name of file005.pdf and so on until the end of files .pdf only. The final result pf all process will be in other words:
file001.pdf - not touched because is ok in order
file002.pdf - not touched because is ok in order
file004.pdf - renamed to file003.pdf
file007.pdf - renamed to file004.pdf
file009.pdf - renamed to file005.pdf
file010.pdf - renamed to file006.pdf
The final files ordered in resume:
And it works perfect with this script:
REM *** Folder in which the files are:
REM *** File prefix until the numeric index:
REM *** File extension to search:
REM *** Length of the numeric index:
call :GetStringLength PrefixLength "%FilePrefix%"
set /a CurrentIndex = 1
for /f "delims=" %%a in ('dir /b /a:-d /o:n "%SourceFolder%\%FilePrefix%*.%Extension%"') do (
call :GetFormattedIndex FormattedIndex !CurrentIndex! %IndexLength%
echo Processing %%a; file index is '!FileIndex!', sequential index is '!FormattedIndex!' ...
if "!FileIndex!"=="!FormattedIndex!" (
echo ... indices match, no change.
) else (
echo ... file index not in sequential order, will rename.
ECHO ren "%SourceFolder%\%%a" "%FilePrefix%!FormattedIndex!.%Extension%"
set /a CurrentIndex += 1
:GetFormattedIndex <ReturnVariable> <Index> <Length>
:GetStringLength <ReturnVariable> <String>
set /a i = 0
if "!__string:~%i%,1!"=="" (
) else (
set /a i += 1
Is there a way to make a translation of code to vb script for use in asp pages in the middle of:
Why because the server block everything that is a .bat and we can´t use or modify the server is not allowed.
I hope someone can help to translate the code to use in a regular .asp page. Not "ASP.NET" simply ASP only.
On the above script the only need to change is the "set SourceFolder=D:\Temp\FileR
ename" and of course the files must be named like I mentioned in the beginning, it means similar names ending in "00x" with extension in .pdf only like this: