I need a batch file that reads the description name present in the XYZ.txt file and rename that file name based on description name.
For example i have a file name c
This will get you started.
for /f "tokens=1,* delims==" %%A in ('find /i "Description" "nest.txt"') do echo %%B
try this:
for /f "skip=1 tokens=1* delims==" %%i in (nest.txt) do ren XYZ.txt "%%~j.txt"
I assume, you have 1000 files with 1000 different names.
@echo off
for /f %%i in ('dir /b *.txt') do (
for /f "skip=1 tokens=1* delims==" %%j in ( %%i ) do (
if "%%j"=="Description" echo ren "%%i" "%%k.txt"
)
)
This will not work on files which have spaces in their (original) filename, but I don't understand, why. (%%i contains only the part before the first space). Maybe someone other can help with this (I'm sure, it's only a minor change, but I can't find it)
Remove the "echo", if the output fits your needs.
(are you sure that all 1000 files have 1000 different Descriptions?)