|
Answer» The below works fine providing that desktop6.ndkOLD1 do not already exist, how can I have it to rename the file in sequence so that it will TRY first desktop6.ndkOLD1 then desktop6.ndkOLD2 etc.
Code: [Select]C: cd\Documents and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data Rename desktop6.ndk desktop6.ndkOLD1 Heres a script doing what you need, first it changes the directory then , it sets variable cn to zero , then it starts a new SECTION and for array in the array it processes all , *.NDKOL?? Files witch is the same thing as *.ndkOLD2 , *.ndkOLD3 , ECT .. it then calls set and adds 1 to the variable CN if the file name .NDKOLD3 already EXISTS , it loops back to the top and adds another 1 to the variable.. and does this untill CN hits a number that doesnt exist yet.. once it finds the next file that doesnt exist , it uses IF /F and LSS , so if desktop6.ndk is LESS then desktop6.NDKOLD4 OR desktop6.NDKOLD%CN% , it will rename the file to Desktop6.NDKOLD%CN% or Desktop6.NDKOLD5 (WHATEVER comes next)
@echo off cd\Documents and Settings\%username%\Local Settings\Application Data\Lotus\Notes\Data set cn=0 :TOP for /f "tokens=1*" %%a in ('dir /a *.ndkOL?? /b') do ( call set /a cn=%%cn%%+1 if exist desktop6.ndkOLD%cn% Goto Top if /i desktop6.ndk LSS %%a rename desktop6.ndk desktop6.ndkOLD%cn% ) :ENDThanks Diablo416, just the thing I needed.
|