Windows - how to list files

Post date: Mar 31, 2013 7:14:04 PM

Some times I need to get list of files in a file with specific criteria, it is simple and easy but remembering those basic commands and syntax is a challenge and I have to do search, research and waste time again and again. Here I am putting all that for my future reference and for some one who is also looking out for the same:

List files without directories and other information inside myfolder:

/b gives you bare format, /S is for subfolders (recursive)

Example:

c:\myfolder>dir /b *.*

New Text Document (2).txt

New Text Document (3).txt

New Text Document (4).txt

New Text Document - Copy (10).java

New Text Document - Copy (11).java

New Text Document - Copy (2).java

New Text Document - Copy (3).java

New Text Document - Copy (4).java

Example:

c:\myfolder>dir /b *.txt

New Text Document (2).txt

New Text Document (3).txt

New Text Document (4).txt

If you want names not the extension:

for /r %i in (*.war) do @echo %~ni>>apps.txt

Example:

c:\myfolder>for /r %i in (*.txt) do @echo %~ni

apps

New Text Document (2)

New Text Document (3)

New Text Document (4)

If you want date and time but not the directory info but just a clean list:

With default date time

DIR /S *.zip | FIND "/"

With specific date time

DIR /S * /T:C .zip | FIND "/"

C=Created

W=Written

Example:

c:\myfolder>DIR /S *.txt | FIND "/"

04/01/2013 12:34 AM 69 apps.txt

04/01/2013 12:30 AM 0 New Text Document (2).txt

04/01/2013 12:30 AM 0 New Text Document (3).txt

04/01/2013 12:30 AM 0 New Text Document (4).txt