I need a batch file that reads the description name present in the nest.txt file and rename that file name based on description name.
For example i have a file name
The following batch file takes one command line parameter and must be run from the folder where the files to be renamed exist. You could easily add more code to the batch file to make it more intelligent (e.g., change to the folder, hard code *.txt
in place of %1
, etc.).
So, if the batch file is called fixfilenames.bat
and is in the same folder with the TXT files, from a command prompt, type fixfilenames *.txt
and it will rename the files first to have the extension temp_txt
so that the for
loop won't pick up the files again after they are renamed. Then when it is done, it renames all temp_txt
files to txt
files.
@echo off
for %%i in (%1) do (
for /f "tokens=2 delims==" %%j in ('findstr /B /I "Description=" "%%i"') do (
ren "%%i" "%%j.temp_txt"
)
)
ren *.temp_txt *.txt