locked
Unique file name RRS feed

  • Question

  • You cannot vote on your own post                    
    0
                

    Hi,

    I have an input file in folder with file name Z.609.091917.083117.091021.prn.txt. I would like my script to read the content of this file but the issue I'm having is how to specify the input file name  as some part of the file name will varies with each day.

    Basically the 083117.091021 will vary. Is there a way to get this file regardless of the charaters of the latter part of the file name?

    Currently I have the below script but it doesn't work.. Please advice

    $previousday = ( get-date ).adddays(-1).ToString('MMddyy')
    $sourcefilename = "Z.609.$previousday*"+".txt"

    $sourcefilename2 = "Z.609." + $previousday + "." + "*****" + "." + "******" + "." + "prn" +".txt"

    $inputpath = "X:\project\Monarch"
    $inputfile = "$inputpath\$sourcefilename" 

    Wednesday, September 20, 2017 6:13 PM

Answers

  • Get-Item "X:\project\Monarch\Z.609*$previousday.prn.txt"


    \_(ツ)_/


    • Edited by jrv Wednesday, September 20, 2017 7:13 PM
    • Marked as answer by Dejip Wednesday, September 20, 2017 7:46 PM
    Wednesday, September 20, 2017 7:13 PM

All replies

  • Get-Item "X:\project\Monarch\Z.609*$previousday.prn.txt"


    \_(ツ)_/


    • Edited by jrv Wednesday, September 20, 2017 7:13 PM
    • Marked as answer by Dejip Wednesday, September 20, 2017 7:46 PM
    Wednesday, September 20, 2017 7:13 PM
  • Thanks
    Wednesday, September 20, 2017 7:46 PM