Topic "Remove leading path from source files (getfiles, multi-file)"

Author Message
[View user's profile]

Joined: 2015-01-05
Posts: 2
This Powershell code is used to download all files from the remove server's "/In" directory.
# Powershell
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
$remotePath = "/In";
$localPath = "D:\temp"; 
$removeRemote = $TRUE;
$transferResult = $session.getfiles($remotePath, $localPath, $removeRemote);

It saves files in "D:\temp\In", but I want the files to be saved in "D:\temp". How do I remove the leading "In" part of the source file names?

WinSCP 5.5.6 (build 4746).
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24755
Location: Prague, Czechia
Using /In tells WinSCP to download the folder, not its contents only. Use /In/*.

Also using D:\temp seems wrong and it should not do what you describe. You should use D:\temp\.

Last edited by martin on 2015-01-06; edited 1 time in total
[View user's profile]

Joined: 2015-01-05
Posts: 2
Thank you very much. It works perfectly.

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License