Quantcast
Channel: SQL Server Teacher
Viewing all articles
Browse latest Browse all 26

How to get the Min and Max Date Modified files in a Large Directory

$
0
0

Hi All,

 

Sometimes we came to a situation to find the min and max dates in a file directory which is very large and will hang up the server if it is opened in windows explorer.

 

Powershell will help us in this type of situation. Please find the commands below to get the min and max files based on date modified.

 

 

The below command gives the top 5 recently modified files in the directory

 

gci path | sort lastwritetime | select Name,lastwritetime -last 5

 

 

The below command gives the first 5 files in the directory sorted by lastwirtetime descending.

 

gci path | sort lastwritetime | select Name,lastwritetime -first 5

 

Regards,

Selvaraj.

 


Viewing all articles
Browse latest Browse all 26

Trending Articles