开发者

Batch programming write dir list to text and edit the text

I would like to read dir (files with extensions) and add some text in front and back of every file with extension. I only know how to list files in txt

dir /b *.IDX > IDX.TXT

and you get IDX.TXT file with:

SOMETHING.IDX
SOMEFILE.IDX
SOMEOTHERFILE.IDX
SOMEFILEETC.IDX
...

and i would like to add in front and in back of *.IDX some text. ex:

NEW TEXT ADDED SOMETHING.IDX MORE NEW TEXT ADDED
NEW TEXT ADDED SOMEFILE.IDX MORE NEW TEXT ADDED
NEW TEXT ADDED SOMEOTHERFILE.IDX MORE NEW TEXT ADDED
NEW TEXT ADDED SOMEFILEETC.IDX MORE NEW TEXT ADDED

when I dir /b *.IDX > IDX.TXT (list files) do I have to put in front and in back some chars like this

$%!SOMETHING.IDX!%$

and use some for loop (WHICH I DON'T KNOW HOW :D ) to replace those chars with my text. How can 开发者_运维百科I do that ?

OS: win xp, win 7.

ps one more thing :D how can search and edit .IDX EX:

SOMETHING.IDX
SOMEFILE.IDX
SOMEOTHERFILE.IDX
SOMEFILEETC.IDX


Try this:

@ECHO OFF 

FOR %%i IN (*.IDX) DO ECHO NEW TEXT ADDED %%i NEW TEXT ADDED
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜