Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows : How to list files recursively with size and last access date?

I need a simple way to create a list of all files in a certain folder. (recursively)

Each file must be in a single line. I also need the file size and the last access date in the same line, separated by a special character.

The output (textfile) should look like this:

c:\folder\file1.txt|400|2012-11-12 15:23:08 c:\folder\file2.txt|200|2012-11-12 15:23:08 c:\folder\file3.txt|100|2012-11-12 15:23:08 c:\folder\sub folder\file4.txt|500|2012-11-12 15:23:08 

'Dir' seems not to be an option, because the German Special characters get messed up that way. (öäüß)

Powershell handles the special characters well, but I couldn't make it so that the information for one file ends up in a single line:

get-childitem D:\temp -rec | where {!$_.PSIsContainer} |  foreach-object -process {$_.FullName, $_.LastWriteTime, $_.Length} 
like image 555
Baine Wedlock Avatar asked Nov 12 '12 14:11

Baine Wedlock


People also ask

How do I recursively list files in Windows?

For example, when listing files in a Windows command prompt, you can use the dir /s command to recursively list all files in the current directory and any subdirectories.

How do I get a list of files and size in Windows?

Go to File Explorer and right-click the Name field. Select Size. File sizes will now display on the right side of the window. Find it in File Explorer, right-click, and then select Properties to see a folder's size.

How do I list files in a full path in Windows?

Listing the full path The command DIR /b will return just a list of filenames, when displaying subfolders with DIR /b /s the command will return a full pathname. To list the full path without including subfolders, use the WHERE command.


1 Answers

try this:

get-childitem D:\temp -rec | where {!$_.PSIsContainer} | select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -delimiter '|' -path file.csv 
like image 191
CB. Avatar answered Oct 08 '22 03:10

CB.