WINSCP synchronize alternatives?

I want to get a directory listing of a remote directory into a textfile using a WINSCP script.  I'm getting "too many parameters for ls command" message.  I've concluded that redirection is not an option.  

Will some wonderful expert please look at this and let me know how I can get a directory listing into a textfile using a WINSCP script?  Thanks.

open ftp://<user>:<pwd>@<ip address>
cd <main folder>
cd <sub folder>
ls > listoffiles.txt
get listoffiles.txt

Open in new window

Who is Participating?
woolmilkporcConnect With a Mentor Commented:
I think winscp.exe /console opens a new window so that output redirection cannot work.
Use instead. It provides the console interface.
Omit the redirection operator. ls in this context takes only one parameter - the name of a local output file.
MariaHaltAuthor Commented:
Tried it, but now I'm getting these errors instead:

Error listing directory 'listoffiles.txt'
Could not retrieve directory listing

It's like ls can't be redirected in WINSCP.

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

OK, obviously you're right. WinSCP obviously doesn't support the 'classic' FTP syntax.
The only thing which seems to work is redirecting the whole output of winscp.exe (or by using standard operators > or |  -
 winscp.exe .... > outfile
The headline of your Q contains 'synchronize ...'. Did you consider using the 'synchronize' facility of WinSCP? Has nothing to do with output redirection, I know ...
MariaHaltAuthor Commented:
I removed everything to the right of the ls command and got rid of the get line too, hoping that the listing would appear in the results.txt file.

I've been running the script from a batch file that contains this line:

C:\PROGRA~1\WinSCP\winscp.exe /console /script=C:\TEMP\mywinscpscript.txt > results.txt

The file, results.txt, is empty!  

As for the synchronize has its own set of problems...the remote directory is huge and the local directory is flushed what happens is all the files in the remote directory get downloaded (again and again)...some are huge and a problem inevitably occurs and the synchronization starts's just not working out.  ( I meant to change that headline.)

I appreciate your help.
When it's just for the directory  listing ...
why not use the standard Windows FTP client?
MariaHaltAuthor Commented:
I tried that luck.  ls just doesn't work like one would expect in ftp mode.
MariaHaltAuthor Commented:
.com worked!  Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.