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.
31 Answer
In the command prompt you can use something like this:
for %a in (*) do @echo %~naTo 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:
2