Link to home
Start Free TrialLog in
Avatar of Marcusw
Marcusw

asked on

server file and directory list

i have a dedicated server that i connect to via ftp to upload and download my websites.

over time i have accumulated over 10000 pages in many different directories.

is there a way that i could write a program that ftps into my server and writes to a text file every filename and folder that its in?

i have found many examples of ftp code but i don't know how i would extract all the info into a file
Avatar of jmwheeler
jmwheeler

I imagine you could work with fso.  Add a reference to 'Microsoft Scripting Runtime' in your project and try this:

'This will create a text file listing every file and folder on a persons C: drive.  You will need to tweak it to work for ftp.  Somehow you will need to link svr to the server and not to the
'hard drive also fldr will need to be set to the root folder you want start with.
'Set svr = fso.GetDrive("C:\")     should need to be something like   Set svr = fso.GetDrive("\\ServerName\Whatever\")
'Set fldr = fso.GetFolder("C:\")

Option Explicit

Private fso As FileSystemObject
Private svr As Drive
Private fldr As Folder
Private fldr2 As Folder
Private fldr3 As Folder
Private fl As File

Private Sub Form_Load()
    Open "C:\OutputFile.txt" For Output As #1

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set svr = fso.GetDrive("C:\")
    Set fldr = fso.GetFolder("C:\")
   
    Print #1, "C:\"
    For Each fl In fldr.Files
        Print #1, vbTab & fl.Name
    Next
   
    For Each fldr2 In fldr.SubFolders
        Print #1, fldr2.Path
        GetFiles fldr2
    Next
   
    Close #1
    MsgBox ("Finished")
End Sub

Private Sub GetFiles(fldr2 As Folder)
    For Each fl In fldr2.Files
        Print #1, vbTab & fl.Name
    Next
   
    For Each fldr3 In fldr2.SubFolders
        Print #1, fldr3.Path
        GetFiles fldr3
    Next
End Sub
Avatar of Marcusw

ASKER

thanks jim i am having trouble with your code though, every time i try to run it as is it produces the following error

user defined type not defined

and highlights

Private Sub GetFiles(fldr2 As Folder)

any ideas
Avatar of Marcusw

ASKER

ive sorted the problem but i cannot get it to connect to my server, could anybody give me the code to connect with thanks
ASKER CERTIFIED SOLUTION
Avatar of Netminder
Netminder

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