TheCodeCache
TheCodeCache

Reputation: 962

How can I sort files based on their last updated time using "dir" command in Windows

I am using "dir" command on the command line prompt in Windows 10. I've tried the following:

c:\my_folder> dir /s /b

but, the above command is not displaying the files according to the last updated time of files.

Upvotes: 4

Views: 5064

Answers (3)

js2010
js2010

Reputation: 27428

cmd:

dir /od

powershell (you can use tab completion on "lastwritetime" or it might popup from the history with the latest psreadline):

dir | sort lastwritetime

Upvotes: 3

Maksim
Maksim

Reputation: 521

Orders the files according to last modified (increasing):

dir /o:-d /t:w

Does the same as above but decreasing (most recent on top of list):

dir /o:-d /t:-w

Upvotes: 1

krokodilko
krokodilko

Reputation: 36097

Open a powershell console and enter this command:

Get-ChildItem | Sort-Object -Property LastWriteTime

If you want descending order, then use:

Get-ChildItem | Sort-Object -Property LastWriteTime -Descending

Upvotes: 7

Related Questions