sftp - how many files

Hello!!

Another sftp question...

I need to know inside the sftp environment how many files exists, or if there is any file, before I do a

mget *

Any ideas?

Thanks in advance
:O)

Try 'ls' command and count output lines (can be sent to pipe).

I don't think that will work. You cannot use pipe at the sftp prompt.

If you can connect via ssh to that system, you can write a simple command that will do the job for you:

ssh -l <user> <host> cd <remote_source_directory> \; ls |wc -l

Note that the ';' is escaped, else you will only do a cd to remote dir. The ls and wc will run in the local shell.

Hope this helps. Cheers!