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

Advertisement

a1
Joined:
Posts:
2

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

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).

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,227
Location:
Prague, Czechia

Re: Remove leading path from source files (getfiles, multi-file)

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

Reply with quote

a1
Joined:
Posts:
2

Re: Remove leading path from source files (getfiles, multi-file)

Thank you very much. It works perfectly.

Reply with quote

Advertisement

You can post new topics in this forum