Search code examples
cachingcmdmanifestlsdir

List files in subdirectories but don't list directories


When I do a dir /s /b command from command prompt I get the ususal files in the directory,subdirectories,and files in the subdirectories.For example:

C:\Files\more_files>dir /b /s
C:\Files\more_files\18.0.1025.39 Dev_chrome_installer.exe
C:\Files\more_files\7z920.exe
C:\Files\more_files\Firefox Setup 2.0.exe
C:\Files\more_files\ie6setup.exe
C:\Files\more_files\qbasic
C:\Files\more_files\sp6i386.exe
C:\Files\more_files\Thunderbird Setup 10.0.1.exe
C:\Files\more_files\qbasic\QBASIC.EXE
C:\Files\more_files\qbasic\QBASIC.HLP
C:\Files\more_files\qbasic\QBASIC.INI

C:\Files\more_files>

But I dont want subdirectories listed,but I want the files in the subdirectories listed.Basically, I want dir to not show subdirectories, but show the files in them.Here is an example with subdirectories removed:

C:\Files\more_files>dir /b /s
C:\Files\more_files\18.0.1025.39 Dev_chrome_installer.exe
C:\Files\more_files\7z920.exe
C:\Files\more_files\Firefox Setup 2.0.exe
C:\Files\more_files\ie6setup.exe
C:\Files\more_files\sp6i386.exe
C:\Files\more_files\Thunderbird Setup 10.0.1.exe
C:\Files\more_files\qbasic\QBASIC.EXE
C:\Files\more_files\qbasic\QBASIC.HLP
C:\Files\more_files\qbasic\QBASIC.INI

C:\Files\more_files>

I removed the qbasic subdirectory from the listing, but it still shows the files in the subdirectory(s).I want to use this for a cahce manifest for a webapp but with a different folder.Also, is there a way to list files in subdirectories but not the subdirectories themselves in Linux using ls?


Solution

  • Try:

    dir /b /s /a-d
    

    /a-d means "A" attribute, "-" no , "d" directories