hi
this one is tricky and hope all the genius out there can help me out of this mess.
I have 1000's of .log files in a folder which are to be renamed sequentially.
but the conditions are.
1. The script should read from a .txt (anyname.txt) file which would contain the starting number sequence ie.. (if the anyname.txt file would contain 00213 or any 5 digit number)
2. The batch file should start renaming from 00214.log..00215.log..00216.log and so on till the end of file count in the folder.
3. After renaming all the files sequentially in the folder the batch script should update the anyname.txt file with the last number of file count to continue on the next run.
I have searched the for this type of batch script but in vain.
pl help me out of this mess
thanx to those who r going to help me out in advance..
joe
renaming .log files
Moderator: DosItHelp
Re: renaming .log files
If the already renamed files are still in the same folder it would have been easy to determine the last number without additional text file. Nevermind.
I assume you want to exclude files where the file names already consist of 5 digits.
Steffen
I assume you want to exclude files where the file names already consist of 5 digits.
Code: Select all
@echo off &setlocal
set "numfile=a.txt"
set /p "n="<"%numfile%"
set /a "n=1%n%"
for /f "delims=" %%i in ('dir /a-d /b "*.log"^|findstr /vix "[0-9][0-9][0-9][0-9][0-9]\.log"') do (
set /a "n+=1"
set "f=%%~i"
setlocal EnableDelayedExpansion
ren "!f!" "!n:~-5!.log"
endlocal
)
>"%numfile%" echo %n:~-5%
Re: renaming .log files
steffen
Oh my god I just cant believe it you have pulled me out of the mess wowwwwww . great
Thank you man so grateful..
Oh my god I just cant believe it you have pulled me out of the mess wowwwwww . great
Thank you man so grateful..
Re: renaming .log files
Welcome joe.