久久久久久久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 超時)
主站蜘蛛池模板: 一区二区三区欧美在线 | 国产成人精品一区二三区在线观看 | 天天视频一区二区三区 | 欧美日韩不卡 | 韩国毛片视频 | 国产精品久久久久久久久久免费看 | 成人免费网站 | 全部免费毛片在线播放网站 | 久久艹免费视频 | 亚洲理论在线观看电影 | 国产精品一区二区欧美黑人喷潮水 | 岛国av免费在线观看 | 日韩精品在线播放 | 久久国产综合 | 欧美日韩中文字幕在线播放 | 特级黄一级播放 | 午夜影院视频在线观看 | 日韩在线观看 | 国产精品久久久久久久久久妞妞 | 日韩午夜影院 | 亚洲激情自拍偷拍 | 国产在线视频一区二区 | 欧美日韩一区二区视频在线观看 | 国产综合精品一区二区三区 | 欧洲一区二区视频 | 亚洲成人自拍 | 国产 亚洲 网红 主播 | 日韩一级黄色片 | 午夜精品一区 | 国产精品久久久久久一区二区三区 | 精品国产一区二区三区性色av | 五月激情婷婷在线 | 国产精品久久久久久久久久 | 国产精品久久久久久久久久久久久 | 国产精品欧美一区二区三区 | 成人教育av | 国产精品v | 久草99| 四虎永久在线精品免费一区二 | 久久狠狠 | 午夜丰满寂寞少妇精品 |