Topic "Upload 2 Files with different names (no wildcards)"

Author Message
Maikl
[View user's profile]

Joined: 2017-06-28
Posts: 1
Location: Austria
Hi,

my problem is this: I have to upload 2 files with different names. One file is created by MS SQL Reporting Services, let's call it Export.csv. The other is created by a Powershell script and contains the MD5 Hash of the first file. Let's call it Hash.txt.

Now I have to upload them and give them a different name (adding a timestamp to the file name). What I have done so far is:

Code:

[...]
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary

$transferResult = $session.PutFiles("C:\PathTo\Export.csv", "Export$(Get-Date -format yyMMddhhmm).csv", $False, $transferOptions)
$transferResult.Check()

$transferResult = $session.PutFiles("C:\PathTo\Hash.txt", "Hash$(Get-Date -format yyMMddhhmm).txt", $False, $transferOptions)
$transferResult.Check()
[...]


This works so far.

My question is: Is there a way to upload these two files in one step, something like

Code:

[...]
$files2upload = @("C:\PathTo\Export.csv", "C:\PathTo\Hash.txt")
$renamedFiles = @()

foreach($file2upload in $files2upload)
{
    $fileInfo = [io.FileInfo] $file2upload
    $renamedFiles += ("{0}{1}{2}" -f $fileInfo.BaseName, $(Get-Date -format yyMMddhhmm), $fileInfo.Extension)
}

$transferResult = $session.PutFiles($files2Upload, $renamedFiles, $False, $transferOptions)
[...]


Thanks for your help!
Michael
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26515
Location: Prague, Czechia
Maikl wrote:
My question is: Is there a way to upload these two files in one step, something like

Why? What do you expect from that?
Advertisements

You can post new topics in this forum






Search

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License