Read lines from a text file and use them to rename files

How can I do the following in a batch file?

I have, for example, two files with the name red.txtandorange.txt

in the same directory folder, I have a text file kite.txtwith content being two file names:

red.txt
orange.txt

How can I read the contents kite.txtin turn from the command line and rename the actual files in my folder?

redkite.txt
orangekite.txt
+3
source share
2 answers
 @echo off
 for /f "delims=" %%a in (kite.txt) do ren "%%a" "%%~nakite%%~xa"
+2
source

for / f "tokens = 1,2 delims =,"% g in (kite.txt) do ren% g% h

OR

for / f "tokens = 1,2 delims =," %% g in (kite.txt) do ren %% g %% h

Use single% on command line or twice in script file

/f kite.txt do

= 1,2 , % g,% h ..

delims =, ( CSV)

first% g , ,

do ren DOS REN 1 (% g) 2 (% h)

do echo% g% h, , .

0

All Articles