28

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}
Baine Wedlock
  • 345
  • 1
  • 4
  • 7

1 Answers1

62

try this:

get-childitem D:\temp -rec | where {!$_.PSIsContainer} |
select-object FullName, LastWriteTime, Length | export-csv -notypeinformation -delimiter '|' -path file.csv
CB.
  • 58,865
  • 9
  • 159
  • 159