Topic "Syntax for filenames with spaces"

Author Message
jsb2210
[View user's profile]

Joined: 2013-06-13
Posts: 10
Hello -

I am having a heck of a time getting the right syntax for winscp when there are spaces in the file names. Works great with no spaces.
I tried replacing the backticks with double quotes, so it is double double quotes. Do I need the back ticks and double double quotes?

$winscp = "C:\Program Files (x86)\WinSCP\winscp.com"
$ftpsite = "sftp://sitename:22 -privatekey=D:\Serverkey\key.ppk"
$ftpdirectory = "/remotefolder"
$outfile = "d:\winscp.out"
$filepath = "D:\path\name name.gpg"


[string] $cmdline1 = "& `"$winscp`" /command `"option batch abort`" `"option confirm off`" "
$cmdline1 += " `"open $ftpsite`" `"cd $ftpdirectory`" `"put $filepath`" `"exit`" > $outfile"

invoke-expression $cmdline1
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
You need: ... `"put `"`"$filepath`"`"`" ...

See https://winscp.net/eng/docs/commandline#syntax

Though in PowerShell, you better use WinSCP .NET assembly:
https://winscp.net/eng/docs/library_powershell
Advertisements

You can post new topics in this forum






Search Site

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