Search Folders / foreach loop upload

Advertisement

JamesM
Guest

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

Reply with quote

Advertisement

JamesM
Guest

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

Reply with quote

Advertisement

You can post new topics in this forum