Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Rob26

PostRe: Problem with %2% as remote dir param in "synchronize

Martin, thanks for the the clear explanation and quick response.
martin

Re: Problem with %2% as remote dir param in "synchronize" script

rob26 wrote:

This problem only occurs when remote folder doesn't incude subfolders:
"/path" fails but "path" works

However:
"/path/folder" succeeds and "path/folder" fails.

Exactly. Any argument with syntax /abc is considered a switch. In this case unrecognised switch.
I have just documented how to deal with that:
https://winscp.net/eng/docs/commandline#two_slashes
rob26

Problem with %2% as remote dir param in "synchronize" script

This problem only occurs when remote folder doesn't incude subfolders:
"/path" fails but "path" works

However:
"/path/folder" succeeds and "path/folder" fails.
rob26

Problem with %2% as remote dir param in "synchronize" script

Using WinSCP Version 5.0.0 (Build 1431)

Here is my script:

option batch abort
option confirm off
option transfer automatic
option reconnecttime 180
option exclude "*/"
open ftps://username:password@domain -passive -implicit
synchronize remote -mirror -criteria=time %1% %2%
exit

If I execute this at commandline:
WinSCP.com /timeout=180 /script="test.txt" /parameter "C:\path" "/path"

I get this returned (note that '%2%' did not resolve):

batch abort
confirm off
transfer automatic
reconnecttime 180
exclude */
Connecting to domain ...
Connected with domain:port, negotiating SSL connection...
SSL connection established. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: [1] username@domain
Comparing...
Local 'C:\path' => Remote '%2%'
Error listing directory '%2%'.
Could not retrieve directory listing
CWD failed. "/%2%": directory not found.
(A)bort, (R)etry, (S)kip: Abort

If I execute this at commandline (note absence of "/" as first char of remote path):
WinSCP.com /timeout=180 /script="test.txt" /parameter "C:\path" "path"

I get this returned (note that '%2%' correctly resolved to remote 'path' this time):

batch abort
confirm off
transfer automatic
reconnecttime 180
exclude */
Connecting to domain ...
Connected with domain:port, negotiating SSL connection...
SSL connection established. Waiting for welcome message...
Connected
Starting the session...
Reading remote directory...
Session started.
Active session: [1] username@domain
Comparing...
Local 'C:\path' => Remote 'path'
Synchronizing...

It appears that "/" as first character, when within quotes as in "/path" causes the second parameter not to resolve.