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
PowershellScripting LanguagesProgramming Languages-Other

Avatar of undefined
Last Comment
projectja

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
SieQ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
projectja

ASKER
thanks guy. It is very useful
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck