根据PowerShell中的扩展名从FTP下载文件 [英] Download file from FTP based on extensions in PowerShell
问题描述
使用以下链接监视FTP文件夹并从中下载文件:
https://jhonatantirado. wordpress.com/2013/12/18/download-and-delete-files-from-ftp-using-powershell/
Have used the following link for monitoring an FTP folder and downloading files from it:
https://jhonatantirado.wordpress.com/2013/12/18/download-and-delete-files-from-ftp-using-powershell/
我只需要下载.xml
个文件.
我是PowerShell的新手,有什么简单的我想念的东西?
I am very new to PowerShell, anything simple that I am missing?
if ($line -ne ''| $_.extension -eq '.bpxml-2014' -or $_.extension -eq '.xml')
{
}
$line
的文件名带有扩展名.如何检查它是否具有扩展名?
The $line
has my filename with extension. How do I check if it has the extension?
推荐答案
使用
if ($line -Like "*.xml" -or $line -Like ".bpxml-2014")
{
...
}
请参见 PowerShell比较运算符.
或者使用在PowerShell脚本中使用的WinSCP .NET程序集查看(my)解决方案:
列出与通配符匹配的文件
Alternatively see (my) solution using WinSCP .NET assembly used from a PowerShell script:
Listing files matching wildcard
只需使用 Session.GetFiles
下载匹配的文件.
And just download the matching files using the Session.GetFiles
.
这篇关于根据PowerShell中的扩展名从FTP下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!