0

So currently I am able to get a list of my directories with the folder name using

dir -directory -name   

And I also know I can use recurse as well to list sub-directories Thank you to Sany

What I would like to create in this list is to show this folder's date modified value. I've looked over the documentation and I'm having difficulty to find the answer I assume if it is there it is likely part of Attributes but I'm uncertain as to how to format it correctly.

Most of the searches I've done are have turned up about excluding files based on date modified, rather than showing the date instead.

Gideon Sassoon
  • 544
  • 1
  • 9
  • 29

1 Answers1

1

You can use Select-Object and what I like to use Export-Csv

Get-ChildItem C:/temp -directory -recurse  | Select-Object FullName, LastWriteTime | Export-Csv -Path list_my_folders.csv -NoTypeInformation

In case you want extract other information as well you can also remove the Select-Object part and you will see all columns which you can select.

Output:

"FullName","LastWriteTime"
"C:\temp\save","21.11.2019 15:34:27"
"C:\temp\test","12.01.2020 05:13:24"
"C:\temp\test\002custom","14.12.2019 01:17:54"
"C:\temp\test\002normal","14.12.2019 01:31:46"
"C:\temp\test\x","13.01.2020 12:51:05"
"C:\temp\test\002normal\normal","14.12.2019 01:31:53"
"C:\temp\test\x\Neuer Ordner","13.01.2020 12:51:05"

Of course you can also use it without Export-Csv:

Get-ChildItem C:/temp -directory -recurse  | Select-Object FullName, LastWriteTime > list_my_folders.txt

But the output is in a format that is harder to work in most cases:

FullName                      LastWriteTime      
--------                      -------------      
C:\temp\save                  21.11.2019 15:34:27
C:\temp\test                  12.01.2020 05:13:24
C:\temp\test\002custom        14.12.2019 01:17:54
C:\temp\test\002normal        14.12.2019 01:31:46
C:\temp\test\x                13.01.2020 12:51:05
C:\temp\test\002normal\normal 14.12.2019 01:31:53
C:\temp\test\x\Neuer Ordner   13.01.2020 12:51:05
Boendal
  • 2,496
  • 1
  • 23
  • 36