Hi,
I have this script that parses through client folders, and copies all files in a designated folder for each client. What I want to do now is to take it one step further and copy all files beneath all subfolders that the client may create. So one client may log in and create a folder and 3 or 4 subfolders underneath with files in each, while another client may log in and create a folder with 8 or 10 subfolders with files underneath. I want to be able to go through all the subfolders for each client and copy all the files in each of the subfolders.
Here is what I already have:
On Error Resume Next
Dim FTPX, FSo, strLocalPath
strLocalPath = "d:\users\"
call ConnectFTP
call CloseFTPConnection
call CreateLocalFolders(strClientname)
Sub ConnectFTP
Set FTPX = CreateObject("CuteFTPPro.TEConnection")
Set FSo = Createobject "Scripting.FileSystemObject")
FTPX.Protocol = "FTP"
FTPX.Port = "21"
FTPX.Host = "192.168.99.48"
FTPX.Login = "internal"
FTPX.Password = "internalpassword"
FTPX.Connect
End Sub
Sub CloseFTPConnection
FTPX.Disconnect
FTPX.Close
End Sub
Sub DownloadFiles(strClientName)
Dim iFileCount
FTPX.LocalFolder = strLocalPath & strClientName & "\incoming\tempmove"
LOCALDIR = FTPX.LOCALFOLDER
FTPX.Download "/userdata/" & strClientName & "/INCOMING/*.*", LOCALDIR
FTPX.RemoteFolder = "/userdata/" & strClientName & "/INCOMING/"
RemoteFolder1 = FTPX.RemoteFolder
L=FTPX.LOCALEXISTS(strLocalPath & strClientName & "\INCOMING\tempmove\*.*")
N = Now()
GetLogName = (((Year(N)*100 + Month(N))*100 + Day(N))) & "incoming.log"
Set ftplog = fspenTextFile(strLocalPath & "logs\" & getlogname, 8, True)
ftplog.writeLine "File Transfer started for " & strClientName
If (L) then
set outfldr=fso.getfolder(localdir)
iFileCount=0
for each file in outfldr.files
iFileCount=iFileCount+1
if FTPX.RemoteExists(RemoteFolder1 & "/" & file.name) then
FTPX.RemoteRemove file.name
else
end if
next
Dim fsoMove
Set fsoMove = CreateObject("Scripting.FileSystemObject")
fsoMove.MoveFile LOCALDIR & "\*.*", strLocalPath & strClientName & "\incoming\"
if err.number <> 0 then
end if
end if
End Sub
Thanks for any help.
Mooge
I have this script that parses through client folders, and copies all files in a designated folder for each client. What I want to do now is to take it one step further and copy all files beneath all subfolders that the client may create. So one client may log in and create a folder and 3 or 4 subfolders underneath with files in each, while another client may log in and create a folder with 8 or 10 subfolders with files underneath. I want to be able to go through all the subfolders for each client and copy all the files in each of the subfolders.
Here is what I already have:
On Error Resume Next
Dim FTPX, FSo, strLocalPath
strLocalPath = "d:\users\"
call ConnectFTP
call CloseFTPConnection
call CreateLocalFolders(strClientname)
Sub ConnectFTP
Set FTPX = CreateObject("CuteFTPPro.TEConnection")
Set FSo = Createobject "Scripting.FileSystemObject")
FTPX.Protocol = "FTP"
FTPX.Port = "21"
FTPX.Host = "192.168.99.48"
FTPX.Login = "internal"
FTPX.Password = "internalpassword"
FTPX.Connect
End Sub
Sub CloseFTPConnection
FTPX.Disconnect
FTPX.Close
End Sub
Sub DownloadFiles(strClientName)
Dim iFileCount
FTPX.LocalFolder = strLocalPath & strClientName & "\incoming\tempmove"
LOCALDIR = FTPX.LOCALFOLDER
FTPX.Download "/userdata/" & strClientName & "/INCOMING/*.*", LOCALDIR
FTPX.RemoteFolder = "/userdata/" & strClientName & "/INCOMING/"
RemoteFolder1 = FTPX.RemoteFolder
L=FTPX.LOCALEXISTS(strLocalPath & strClientName & "\INCOMING\tempmove\*.*")
N = Now()
GetLogName = (((Year(N)*100 + Month(N))*100 + Day(N))) & "incoming.log"
Set ftplog = fspenTextFile(strLocalPath & "logs\" & getlogname, 8, True)
ftplog.writeLine "File Transfer started for " & strClientName
If (L) then
set outfldr=fso.getfolder(localdir)
iFileCount=0
for each file in outfldr.files
iFileCount=iFileCount+1
if FTPX.RemoteExists(RemoteFolder1 & "/" & file.name) then
FTPX.RemoteRemove file.name
else
end if
next
Dim fsoMove
Set fsoMove = CreateObject("Scripting.FileSystemObject")
fsoMove.MoveFile LOCALDIR & "\*.*", strLocalPath & strClientName & "\incoming\"
if err.number <> 0 then
end if
end if
End Sub
Thanks for any help.
Mooge