Listing files using dir /s

chima
chima used Ask the Experts™
on
This question is more out of curiosity, mainly because I could not make it work.  I am sure there is a batch file to do this, but I wonder if there is a command line command to; display only the file names under each subdirectory.  It would be a: dir /b  but once I add /s then the subdirectory path is listed for each file.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Paste the script below into a text file with a .cmd extension.  Customize the value of the folder variable with the location of the folder to search under.  Running the script will echo just the filenames.


@echo off
setlocal
 
set folder=c:\files
 
for /F "tokens=*" %%G in ('dir "%folder%" /A:-D /B /S') do echo %%~nxG

Open in new window

Commented:
dir/s/w will give you only the file names

Author

Commented:
Shift-3, I will try this later on in the day.  silemone, thank you I appreciate your response.

Commented:
good luck

cheers...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial