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.

Denzell
  • 121
  • 1
  • 3
  • 9
  • Possible duplicate of [How do I hide file extensions in a command prompt /dir output?](https://superuser.com/questions/223156/how-do-i-hide-file-extensions-in-a-command-prompt-dir-output) or https://stackoverflow.com/questions/54962981/how-to-show-only-filenames-without-extensions-using-dir-command – spikey_richie Aug 29 '19 at 09:53
  • Is PowerShell an option? Check out `Get-ChildIem | select Basename` (short version `(gci).Basename'`) or `gci | format-wide -Property Basename -Column 3` – Keith Miller Aug 29 '19 at 13:15
  • Possible duplicate of [Cannot install any updates on clean Windows 8.1](https://superuser.com/questions/1120602/cannot-install-any-updates-on-clean-windows-8-1) – Moab Aug 29 '19 at 15:25

1 Answers1

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

Ricardo Bohner
  • 3,903
  • 2
  • 18
  • 12