1

I am new to WinSCP and PowerShell.
I am trying to look for files in a directory that has the pattern "ABC"+somenumbers+YYYYMMDD+somenumbers.zip

$dt = (Get-Date).ToString('yyyyMMdd') 
$transferOptions.FileMask = ("ABC*>=" "+$dt+".zip")

I am not able to get any files downloaded to local directory. Is my file mask correct?

Thanks
MR

5
  • Would you confirm that that is actually what you have for the filemask, as it looks to me as if there is a typo. Also, the > syntax appears to be for the file modified time, not something you can use within the filename portion. Commented Jul 31, 2018 at 16:52
  • The file name has today's date with format YYYYMMDD. I didn't know >= is only for modified dates Commented Jul 31, 2018 at 17:00
  • 1
    I suspect you want $transferOptions.FileMask = "ABC*$dt.zip". Commented Jul 31, 2018 at 17:08
  • See also stackoverflow.com/q/43746835/850848#43776537 Commented Aug 1, 2018 at 5:13
  • 1
    @MartinPrikryl I think I missed the second "*", but I put it in the answer. Commented Aug 1, 2018 at 9:55

1 Answer 1

1

As the date is part of the filename, you don't need to use the ">" syntax in the filemask, which would be for the file modified time.

Powershell will expand variables inside double-quoted strings (Variable expansion in strings and here-strings), so you can use

$transferOptions.FileMask = "ABC*$dt*.zip"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.