0

I've been using dir /b to display all files and folders in a directory but it includes the file extension for every file in a directory. What is the command for displaying all files without including their extension?

Example:

A entered dir /b inside a directory and it displays the following:

Avengers Endgame (2019).mp4
Thor Ragnarok (2017).mp4
....................

What I want is this:

Avengers Endgame (2019)
Thor Ragnarok (2017)

To be displayed in command prompt without including their file extensions.

3

1 Answer 1

0

In the command prompt you can use something like this:

for %a in (*) do @echo %~na

To include Folders in the result:

dir /ad /b & For %a in (*) do @echo %~na

But at some point it might be difficult to tell the difference between a folder and a file so maybe you may want to do something like this:

echo. & echo Folders: & echo. & dir /ad /b & echo. & echo Files: & echo. & For %a in (*) do @echo %~na

This would result in something like this:

enter image description here

2
  • thank you! But how do I include the folders in the list?
    – Denzell
    Commented Sep 1, 2019 at 3:14
  • Just edited the answer... Commented Sep 1, 2019 at 10:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .