Select file based on file name order

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 8 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33708
    Profile photo of Nathan W
    Nathan W
    Participant

    Hello,

    I am working on a script to process data on some flat files and I need a way to select just the first file in the directory where the files are located based on the name of the file. the files will be ordered alphabetically. Once the file is process it is removed from the directory so later in my script I look to see if there is still files in the directory and process again if there are.
    As always thanks for the assistance!!!

    #33709
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Sort-Object and Select-Object should do the trick:

    $firstFile = Get-ChildItem c:\SomeFolder | Sort-Object -Property Name | Select-Object -First 1
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.