Search code examples
filelistbatch-filefile-extensionfilelist

Batch: How to make a .txt file with all files in a folder without extensions


right now i have this code:

@echo off

dir Maps /A-D /b /o:gne >Maplist.txt

start notepad Maplist.txt

But i makes Maplist.txt like this:

a.bsp

b.bsp

c.bsp

but i want it without ".bsp"

please help


Solution

  • You need to read up on the FOR command - type HELP FOR or FOR /? from the command window to see the documentation.

    The following code will do exactly what you want.

    @echo off
    >Maplist.txt (
      for %%F in (Maps\*) do @echo %%~nF
    )
    start notepad Maplist.txt