Search code examples
listbatch-filedir

Remove and replace text in .txt file with .BAT file


Right now I have a very simple DIR .BAT file to list XLS files. I need to delete the file extension & unneeded parts from the list. What is the simplest way to do this?

Right now I just have this:

DIR /b /on *.XLS > LIST.TXT

which gives me an output of:

00000+00-f.xls
00960+83-f.xls
01911+82-f.xls
01939+53-f.xls
02225+79-f.xls

But I would like it to reformat to

00000+00
00960+83
01911+82
01939+53
02225+79

Any ideas on how to this with just one .BAT file?


Solution

  • @echo off
    (for /f "delims=-" %%a in ('DIR /b /a-d /on *.XLS') do echo %%a)>file.txt