for /r %i in (*) do @echo %~ni
or
forfiles /s /c "cmd /c if @isdir==FALSE noquotes.bat @fname"
assuming a file noquotes.bat in your %PATH% with this content
@echo %~1
for /r approach explained
for /r walks the current directory recursively (you can specify a directory for /r drive:\path\, the current directory is assumed) and executes the command specified by do for each file matched in the set (*). The set (.) would match only directories. @echo %~ni
This command works as-is from the prompt. Double up on your quotes if you put it inside a batch file. i.e. for /r %%i in (*) do @echo %%~ni
forfiles approach explained
/s enumerates the current and all subdirectories
/c executes the command inside the quotes
@isdir and @fname is a symbol emitted into the command string
The extra batch file noquotes.bat helps by stripping the double-quotes with %~1 (parameter 1)
forfiles also allows you to specify a path to start at forfiles /P C:\Windows ...