Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy files from subfolders beneath designated folder

Status
Not open for further replies.

moogeboo

MIS
Aug 7, 2003
28
0
0
US
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 = fso_OpenTextFile(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 would suggest you take a look at the robocopy resource kit utility. It is easily scripted and would allow you to copy only new or changed files.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top