# Display the files from sub-folders without the path in front of the file name

Basically, I want to list all the SQL files from a folder called Scripts. I am doing this in the following way:

dir /s /b "D:\Scripts\*.sql"


(I am specifying the full path as I want this to work from wherever I write this command)

This is showing me the list of files somewhat like:

D:\Scripts\subfolder1\foo.sql
D:\Scripts\subfolder1\bar.sql
D:\Scripts\subfolder2\baz.sql


I would like to print just:

foo.sql
bar.sql
baz.sql


Is this possible from a single command? Thanks in advance.

-

for /r D:\Scripts %a in (*.sql) do @echo %~nxa

for /f "tokens=*" %a in ('dir /s /b "D:\Scripts\*.sql"') do echo %~nxa