• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

How to output folder names in FTP folder into a text file ?

Chaps, is there a way to copy all of the folder names within an FTP folder and output it to text? Either with a batch file or just by command prompt?

We've logged on with the command prompt in windows, then used the command:

dir *.* /b >> filenames.txt

This doesn't work. Any ideas?

1 Solution
Bill PrewCommented:
I can't recal if Windows FTP client supports this, but seems to me we used to this on unix.

dir . filenames.txt

Open in new window

Is your FTP folder local or remote?
YashyAuthor Commented:
The FTP folder is remote
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

You could do this with a Robo-FTP script.  Here is an example that parses a directory listing returned by the FTP server and writes only the names of the folders to a file. To make it work you'll need to change the login information on the FTPLOGON command line (4th line) but it should otherwise work for you.
SET output_file = "c:\ftp_folder_list.txt"
* remove existing file so we start with an empty one
DELETE output_file  
FTPLOGON "ftp.mydomain.com" /user="UserID" /pw="Secret"
* process directory listing returned by FTP server
GETSITEFILE "*" /next /incldirs
* skip files in the directory listing
IFSTRCMP %sitedir "" GOTO look_for_folder
WRITEFILE output_file %sitedir /append
GOTO look_for_folder

Open in new window

YashyAuthor Commented:
Genius Alex. Thanks man.
Bill PrewCommented:
Did my first post not work for you, seems to work for me using the base Windows FTP client.  The same approach works with the ls subcommand as well, if you just want names and no size / date info.

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.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now