Topic "Syntax for filenames with spaces"

Author Message
[View user's profile]

Joined: 2013-06-13
Posts: 11
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\"
$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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
You need: ... `"put `"`"$filepath`"`"`" ...


Though in PowerShell, you better use WinSCP .NET assembly:

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License