windows command line dir command: to display only the file name, in 8.3 format?

for /R %A in (*.*) do @echo %~nsA %~nA

without subdirectory:

for %A in (*.*) do @echo %~nsA %~nA

add hidden files:

for /F "tokens=*" %A in ('dir /B/A:-/S *') do @echo %~nsA %~nA

without subdirectory:

for /F "tokens=*" %A in ('dir /B/A:- *') do @echo %~nsA %~nA

If you just want the 8.3 names and nothing else to be displayed, if you use "dir /-n" you will get the 8.3 name at the beginning of each line. Note: it separates the extension from the filename with a space rather than a period.

C:\Users\User>dir /-n
 Volume in drive C has no label.
 Volume Serial Number is 5C60-1B61

 Directory of C:\Users\User

.             <DIR>             01/28/2015  11:26 PM
..            <DIR>             01/28/2015  11:26 PM
Contacts      <DIR>             12/27/2014  04:46 PM
Desktop       <DIR>             01/25/2015  05:06 PM
DOCUME~1      <DIR>             01/27/2015  10:20 PM
DOWNLO~1      <DIR>             01/27/2015  10:10 PM
FAVORI~1      <DIR>             12/27/2014  04:46 PM
GOOGLE~1      <DIR>             01/28/2015  02:08 AM
Links         <DIR>             01/25/2015  05:06 PM
Music         <DIR>             12/27/2014  04:46 PM
Pictures      <DIR>             12/27/2014  04:46 PM
SAVEDG~1      <DIR>             12/27/2014  04:46 PM
Searches      <DIR>             12/27/2014  04:46 PM
TESTIN~1 TXT                  8 01/28/2015  10:32 PM
TESTIN~2 BAT                175 01/28/2015  11:26 PM
TESTIN~1 BAT                164 01/28/2015  11:26 PM
UNIGIN~1      <DIR>             10/28/2014  07:01 PM
Videos        <DIR>             12/27/2014  04:46 PM
               3 File(s)            347 bytes
              16 Dir(s)  3,896,034,717,696 bytes free

But you can use the "dir /-n" within a for loop in a batch file then extract a substring of the first 12 characters to get rid of the rest of each line. E.g.:

@echo off
setlocal EnableDelayedExpansion

for /f "skip=7 tokens=*" %%i in ('dir /-n ^| find /v "File(s)" ^| find /v "Dir(s)"') do (
   set x=%%i
   echo !x:~0,12!
)

The "skip=7" skips the first 7 lines, which aren't file nor directory names and the output of the "dir /-n" is piped through two find commands to remove the last two lines produced by "dir /-n" (the pipe symbol "|" needs to be "escaped" by a "^". Since the substring extraction occurs in a for loop in the batch file, "setlocal EnableDelayedExpansion" is needed and "!" needs to be used with the variable x rather than "%". For the above example, you would then see the following output from executing the batch file:

C:\Users\User>testing456
Contacts
Desktop
DOCUME~1
DOWNLO~1
FAVORI~1
GOOGLE~1
Links
Music
Pictures
SAVEDG~1
Searches
TESTIN~1 TXT
TESTIN~2 BAT
TESTIN~1 BAT
UNIGIN~1
Videos