Link to home
Create AccountLog in
Avatar of projectja
projectja

asked on

newest file name in a directory

Hi,

I am preparing a script with Powershell.

I'd like to get the newest file name in a directory and assign the name to a string variable.

I've just written this one. I have a question:

 dir  C:\PREPARACION\logs | sort -prop LastWriteTime | select -last 1

output:


Mode                LastWriteTime     Length Name                                                                                                                          
-a---          9/6/2011  11:38 PM     442200 aswSnx.sys


However, what I want is to assign "aswSnx.sys" file name to a string.

Any advice?

Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of SieQ
SieQ
Flag of Poland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of projectja
projectja

ASKER

thanks guy. It is very useful