user2726975
user2726975

Reputation: 1353

Selecting files with current date in file name in WinSCP and PowerShell

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

Upvotes: 1

Views: 809

Answers (1)

Andrew Morton
Andrew Morton

Reputation: 25023

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"

Upvotes: 1

Related Questions