Link to home
Start Free TrialLog 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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of projectja
projectja

ASKER

thanks guy. It is very useful