It gets choked after the first dozen.
It takes over 20 seconds to rename 31 files with corrected double extensions, but that is no problem.
I just want it to validate 31 files and take near zero time when nothing needs fixing.
All the files start life with single extension names in the format
???????????????????-00-00.mrimg through to
???????????????????-31-31.mrimg
I wish to rename
???????????????????-00-01.mrimg through to
???????????????????-31-31.inc.mrimg
but to preserve without renaming
???????????????????-00-00.mrimg the initial file
???????????????????-??-??.inc.mrimg previously renamed files
???????????????????-??-??.DIF.mrimg externally renamed files
This is the code to improve
Code: Select all
FOR %%X IN (E*.mrimg) DO ECHO %%X | FIND /I "INC.MriMg" > NUL && (ECHO retain %%X) || (
ECHO %%X | FIND /I "dec.MriMg" > NUL && (ECHO retain %%X) || (
ECHO %%X | FIND /I "-00-00.MriMg" > NUL && (ECHO Retain FULL %%X) || (
ECHO Renaming %%X as *.inc.mrimg
REN %%X *.inc.mrimg
) ) )
Below for your convenience is my complete test code which can be run from the command prompt,
and in the first run it simply creates the 31 files with the single extension in much less than 1 second
When run the second time it renames all excepting the *-00-00.mrimg in over 20 seconds, but I can live with that.
When run the third and subsequent times it takes 9.050 seconds to decide all 31 files need no fixing.
When run with the argument # it deletes all the E*.mrimg files so it can start afresh with 31 single extension files
I developed the timing measurement code when I used XP and before my Win 7 battles fried my brain ! !
Code: Select all
ECHO OFF
ECHO %TIME%
IF %1#==## DEL E*.MRIMG
FOR /F "tokens=1-4 delims=:." %%d in ("%TIME%") do (
SET /A T1=%%d*360000+1%%e*6000+1%%f*100+1%%g-610100
)
FOR %%X IN (E*.mrimg) DO ECHO %%X | FIND /I "INC.MriMg" > NUL && (ECHO retain %%X) || (
ECHO %%X | FIND /I "dec.MriMg" > NUL && (ECHO retain %%X) || (
ECHO %%X | FIND /I "-00-00.MriMg" > NUL && (ECHO Retain FULL %%X) || (
ECHO Renaming %%X as *.inc.mrimg
REN %%X *.inc.mrimg
) ) )
echo %TIME%
FOR /F "tokens=1-4 delims=:." %%d in ("%TIME%") do (
SET /A T2=%%d*360000+1%%e*6000+1%%f*100+1%%g-610100-%T1%
)
ECHO DURATION = %T2%0 mSec
IF EXIST E*.mrimg GOTO :EOF
echo creating
FOR /L %%X IN (0,1,9) DO ECHO %TIME% > E4F3BDD38CC36FC5-0%%X-0%%X.mrimg
FOR /L %%X IN (10,1,30) DO ECHO %TIME% > E4F3BDD38CC36FC5-%%X-%%X.mrimg
DIR E*.mrimg
ECHO %TIME%
GOTO :EOF
NB I never got the hang of VBS and think it is too late for me now ! !
Regards
Alan