SFTP PUT wild card xml files

Advertisement

Naughtikus
Joined:
Posts:
1
Location:
Norway

SFTP PUT wild card xml files

Hello all.

I found example from https://winscp.net/eng/docs/script_locking_files_while_uploading to use for our uploads to remote server. However I need to send out two (or later possible more) type of xml files. Lets call them rabbit*.xml and bunny*.xml.

If its just this... works fine...
$session.PutFiles(($localPath + "*.xml"), ($remotePath + "*.*" + $suffix),
                $False, $transferOptions)
But when I try to add in that rabbit*.xml AND bunny*.xml I start getting different types of errors. Especially if there are no files in the local directories. So 1) how to make it 0 (not error) even if there are no files in the local directory and b) can I add in more than one file names here or should I do another
$transferResult =
    $session.PutFiles(($localPath + "bunny*.txt"), ($remotePath + "*.*" + $suffix),
        $False, $transferOptions)
Under the first one?

Thanks!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,378
Location:
Prague, Czechia

Re: SFTP PUT wild card xml files

You have to use two Session.PutFiles calls, one for "rabbit*.xml" and one "bunny*.xml", if that's what you ask for.

Another option is to use TransferOptions.FileMask with "rabbit*.xml; bunny*.xml", which would allow you to use one call only.

Reply with quote

Advertisement

You can post new topics in this forum