'Copy the file with folder structure from Linux to Windows using WinSCP and delete file which ever is copied and keep the folder
PowerShell or WinSCP – need to download the file and folder structure and delete the file which ever is copied and delete the file but not folder structure.
Solution 1:[1]
It's easy with WinSCP .NET assembly and a PowerShell script.
$result = $session.GetFilesToDirectory($remotePath, $localPath)
$result.Check()
foreach ($result.Transfers as $transfer)
{
$session.RemoveFile($transfer.FileName)
}
An alternative approach, that deletes each file individually right after it is downloaded, is shown in this article:
Recursively move files in directory tree to/from SFTP/FTP server while preserving source directory structure
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Martin Prikryl |