Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

prbrown

Hi JamesM

Is it possible to see your trick I'm trying to do nearly the same thing.

Thanks.
JamesM

Hi Martin

Thanks for your response. Good to know that WinSCP doesn't support file masks in that way.

What I did was create an array of the different folder names and put the initial ForEach loop inside another of this array, it seemed to do the trick!

Cheers
martin

Re: Search Folders / foreach loop upload

WinSCP does not support file masks like this.

You have to list subfolders in respective parent folders and loop over them (three nested loops).

Another option is using Session.EnumerateRemoteFiles:
https://winscp.net/eng/docs/library_session_enumerateremotefiles
But that's probably not the best solution in your case (with fixed $folder\files).
JamesM

Search Folders / foreach loop upload

Hi guys

I'd like to mirror the powershell command:

foreach ($folder in $folderarray) {

Copy-Item "D:\Users\username\*\*\*\$folder\files\*" -Destination
"D:\Users\username\Desktop\temp\" -Recurse
}


in a way that instead of moving files from one local folder to another the files are moved to an SFTP (the SFTP session is working fine and uploading files is not a problem in general.)

This is what I'd attempted to do:

foreach ($folder in $folderarray) {

$session.PutFiles("D:\Users\username\*\*\*\$folder\files\*", "/NewRelease/$folder/", $False, $transferOptions)


But this set up doesn't work in the same way, could someone please tell me I can set this up correctly?

Thanks