久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 FTP 服務器下載名稱包含特定字符串的文件

Download files whose name contains a specific string from an FTP server(從 FTP 服務器下載名稱包含特定字符串的文件)
本文介紹了從 FTP 服務器下載名稱包含特定字符串的文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我沒有使用 PowerShell 的經驗,我需要幫助才能從 FTP 服務器下載多個名稱相似的圖像.我在這個論壇找到了很多,我只設法下載了一張圖片.為此,我必須輸入文件名.

I am not experienced with PowerShell and I need help to download several images with similar names from an FTP server. I found a lot in this forum, and I only managed to download one picture. For this I had to enter the name of the file.

我想選擇一個日期,然后下載該日期的所有圖片并將它們保存在本地文件夾中.我還想將下載圖像的名稱保存在 .txt 文件中

I would like to select a date and then download all the pictures with this date and save them in a local folder. I would also like to save the names of the downloaded images in a .txt file

那么如何根據日期下載圖片呢?

So how can I download the pictures based on the date?

字符串20201009是日期,后面的數字是連續的.

The string 20201009 is the date and the numbers after it are sequential.

希望你明白我的意思,因為這是我第一次在論壇上寫東西

I hope you understand what I mean, because it is my first time that I write something in the forum

$UserName = "abc"
$Password = "abc"

$RemoteFileName =  "DatenTestKam3_schlecht_20201009_085248_00848.jpg"
$LocalFilePath = "C:UsersDesktopPowerShell$RemoteFileName"

$ServerName = "10.196.195.167/22_test"

$webclient = New-Object System.Net.WebClient

$webclient.Credentials = New-Object System.Net.NetworkCredential($UserName, $Password)

$uri = New-Object System.Uri("ftp://$ServerName/$RemoteFileName")

$webclient.DownloadFile($uri, $LocalFilePath)

推薦答案

如果我理解你的問題,你想下載所有名稱包含20201009"的文件.字符串,對吧?

If I understand your question correctly, you want to download all files whose name contains "20201009" string, right?

$url = "ftp://ftp.example.com/remote/path/"
$credentials = New-Object System.Net.NetworkCredential("username", "password")
$request = [System.Net.WebRequest]::Create($url)
$request.Credentials = $credentials
$request.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory
$response = $request.GetResponse()
$reader = New-Object IO.StreamReader $response.GetResponseStream() 
$listing = $reader.ReadToEnd()
$reader.Close()
$response.Close()

$localpath = "C:UsersDesktopPowerShell"
$date = "20201009"
$files =
    ($listing -split "`r`n") |
    Where-Object {$_ -like "*$date*"}

$webclient = New-Object System.Net.WebClient 
$webclient.Credentials = $credentials

foreach ($file in $files)
{
    $localfilepath = (Join-Path $localPath $file)
    Write-Host ($file + " => " + $localfilepath)

    $webclient.DownloadFile(($url + $file), $localfilepath)
}


如果您使用 WinSCP .NET 程序集,那就更簡單了:

Add-Type -Path "WinSCPnet.dll"

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Ftp
    HostName = "ftp.example.com"
    UserName = "username"
    Password = "password"
}

$session = New-Object WinSCP.Session

$session.Open($sessionOptions)

$localpath = "C:UsersDesktopPowerShell"
$date = "20201009"
$session.GetFilesToDirectory("/remote/path", $localpath, "*$date*").Check()

$session.Dispose()

(我是 WinSCP 的作者)

這篇關于從 FTP 服務器下載名稱包含特定字符串的文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 免费不卡一区 | 国产 日韩 欧美 制服 另类 | 中文在线一区二区 | 亚洲综合字幕 | 九九久久久| 日本一区二区高清不卡 | 久久天堂 | 国产成人高清 | 日韩视频在线观看一区二区 | 久久精品久久综合 | 国产精久久久 | 国产精品777一区二区 | 成人一区二区三区在线 | 狠狠干网站| 日韩av三区 | 国产精品三级 | 国产成人一区二区三区精 | 999热视频 | 亚洲国产精品久久久久婷婷老年 | 亚州无限乱码 | 精品中文字幕一区二区三区 | 国产中文原创 | 国产精品成人久久久久 | 91精品国产91久久久久久不卞 | 亚洲精品一区二区二区 | 日韩一区二区三区视频 | 在线成人 | 久久久123 | 久久国产免费看 | 免费在线观看黄视频 | 狠狠艹| 国产传媒在线观看 | 综合二区 | 欧美视频一区二区三区 | 一区| 亚洲不卡在线观看 | 欧美九九 | 人人天天操| 亚洲最新在线视频 | 91精品在线看 | 超碰成人在线观看 |