Friday, April 10, 2015

[Linux, Windows, CMD, MATLAB, Command] Get file list in directory and subdirectory

In Windows,

1. open the 'cmd'.
2. go to the location where the files are stored.
3. then,

  • dir /s /b filename
  • dir /s /b [wildcards]  e.g., dir /s /b *.txt

Option.
if you want to output the list as a file,

  • dir /s /b filename > output_list.txt

if you want to sort names, add '| sort'

  • dir /s /b filename | sort > output_list.txt

In MATLAB,


  • dos(['dir /s /b *.txt > output_list.txt']);




In Linux,


  • find . -iname <filename>


if you want only files not directories,

  • find . -iname <filename> -type f


if you want to use wildcards,

  • find . -iname "*.txt" -type f


other methods,

  • find . | grep "\.txt$"

No comments:

Post a Comment