Link to home
Start Free TrialLog in
Avatar of spoowiz
spoowizFlag for United States of America

asked on

Count number of files in ftp account

Hi,
I have an ftp account which I logged into win Win2000 using command prompt screen.
After I get to a directory where there are thousands of files, what is the command to count the # of files?
thank you,
phil
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

When connected to the server via FTP, try:
ls [remote-directory] [local-file]    # list the files & redirect the output to a file on your system
!wc -l [local-file]                          # Run a local shell process to count the lines in the file
if your win2k ftp has no command for it, then you only can write a script to do it
BTW, to know the number of files while using ftp is useless, in most cases .. Or do you knwo a good reason?
Avatar of spoowiz

ASKER

tfewster - funny. didn't get the email from ee for your response.
suppose i'm already in the directory, please tell me the commands with examples?
i don't think "ls file" would do.

ahoffmann - why is number of files useless?

thanks
> why is number of files useless?
wrong question!
must be: what is it usefull for?
I don't know what it's useful for, but while connected via ftp, try:

ftp> ls . listing    
ftp> !wc -l listing

(If ftp gives you the prompt "output to local-file: listing?", type Y to confirm; Or you can disable prompting)

Note that the number `wc -l` returns will include the "total blocks" line returned by the ls command - If absolute accuracy is required, you could grep that out.
Avatar of spoowiz

ASKER

1.  >ls . listing
it says output truncated to 2000 matches. my other ftp program says the same thing. of course, i have a lot more than 2000 files.
2. >!wc -l listing
says: 'wc' is not recognized as an internal or external command,
operable program or batch file.

sorry, thought it was an easy thing. when solved, i will increase the points to 150.
ls . listing
!find /C " " listing
SOLUTION
Avatar of tfewster
tfewster
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spoowiz

ASKER

ftp> ls . listing
200 PORT command successful
150 Connecting to port 29538
226 Output truncated to 2000 matches
ftp: 26480 bytes received in 0.63Seco
ftp> !find /C " " listing
FIND: Parameter format not correct

thanks for the try. above is the result. still not doing it. any other ideas?
ftp is on unix, i believe. the host is lunarpages.com
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of spoowiz

ASKER

eric - good try. however, it still truncates to 2000 matches
i guess there's no solution.
for trying, i will award 50 points each. thanks.
whow, roughly 10 lines of description how to click some buttons, and the same result as with 2 simple command previously suggested 2 times.
No offence, just wondering ...
Avatar of spoowiz

ASKER

ahoffmann - sorry. it's because the other 2 lines with wc and find didn't work for me. i pasted the error and there was no response to it.
ftp> !find /C " " listing
FIND: Parameter format not correct

thank you for trying - and that' why i awarded 50 each.