olippuner
olippuner

Reputation: 403

Windows CLI list requirement: dir /n/s list, but one line per file dir /b/s and with inline full path

I frequently use a batchscript dirlist.bat to generate a quick searchable text to find file information.

dirlist.bat

dir *.* /b/s >dirlist.txt

now I need additionally date and size information. As this would build a multicolumn list a csv-listoutput would be prefered.

This is my inspiration:

dir *.doc? /n/s >dirlist.txt 

but I get a mixed multiline output. Filematches and folder summaries are intermingled.

Do you know a script approch to list the base information of each filematch into one line?

Upvotes: 0

Views: 757

Answers (2)

Compo
Compo

Reputation: 38604

You could probably use ForFiles.

Example:

@(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt

Upvotes: 1

user7818749
user7818749

Reputation:

Why not just run a loop and get the date and filesize with it?

for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt

you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?

Upvotes: 1

Related Questions