Hi All,
I have a situation like , i have folder in which excel file are present in following Manner.
A_1.xls
A_2.xls
A_3.xls
B_1.xls
B_2.xls
B_3.xls
.
.
.
.
.
now i want to move A files in some location at share point , and B at some other location at share point.
I want to match only first string of file name and based on this i want to move these files.
Till now i have a vb script which uploads the all files from source folder to particular destination on share point. But this is not for my requirement.
Please help for my requirement.
I am attaching my VBSCRIPT.
Const basedir = "E:\Reports"
WebUploadDir "E:\Reports", "http://teamsite/", "Username", "Password"
Function WebUploadDir (dir, baseUrl, usr, pwd)
Set fso = CreateObject("Scripting.FileSystemObject")
Set srcFolder = fso.GetFolder(dir)
Dim fl
Set files = srcFolder.files
For Each fl in files
Dim relpath
relpath = Right(fl.path,Len(fl.path)-Len(dir)-1)
relpath = Replace(relpath, "\", "/")
' msgbox("relpath = " & usr)
'msgbox("relpath = " & pwd)
' msgbox("Baserelpath = " & baseUrl & relpath)
WebUploadFile fl.path, baseUrl & relpath, usr, pwd
Next
Dim sf
Set subfold = srcFolder.SubFolders
For Each sf in subfold
Set f = fso.GetFolder(sf)
relpath = Right(f,Len(f)-Len(basedir)-1)
relpath = Replace(relpath, "\", "/")
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "MKCOL", baseUrl & relpath, False, usr, pwd
objXMLHTTP.send
WebUploadDir f , baseUrl, usr, pwd
Next End Function
Function WebUploadFile (file, url, user, pass)
Dim objXMLHTTP
Dim objADOStream
Dim arrbuffer
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.LoadFromFile file
arrbuffer = objADOStream.Read()
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "PUT", url, False, user, pass
objXMLHTTP.send arrbuffer
End Function
I have a situation like , i have folder in which excel file are present in following Manner.
A_1.xls
A_2.xls
A_3.xls
B_1.xls
B_2.xls
B_3.xls
.
.
.
.
.
now i want to move A files in some location at share point , and B at some other location at share point.
I want to match only first string of file name and based on this i want to move these files.
Till now i have a vb script which uploads the all files from source folder to particular destination on share point. But this is not for my requirement.
Please help for my requirement.
I am attaching my VBSCRIPT.
Const basedir = "E:\Reports"
WebUploadDir "E:\Reports", "http://teamsite/", "Username", "Password"
Function WebUploadDir (dir, baseUrl, usr, pwd)
Set fso = CreateObject("Scripting.FileSystemObject")
Set srcFolder = fso.GetFolder(dir)
Dim fl
Set files = srcFolder.files
For Each fl in files
Dim relpath
relpath = Right(fl.path,Len(fl.path)-Len(dir)-1)
relpath = Replace(relpath, "\", "/")
' msgbox("relpath = " & usr)
'msgbox("relpath = " & pwd)
' msgbox("Baserelpath = " & baseUrl & relpath)
WebUploadFile fl.path, baseUrl & relpath, usr, pwd
Next
Dim sf
Set subfold = srcFolder.SubFolders
For Each sf in subfold
Set f = fso.GetFolder(sf)
relpath = Right(f,Len(f)-Len(basedir)-1)
relpath = Replace(relpath, "\", "/")
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "MKCOL", baseUrl & relpath, False, usr, pwd
objXMLHTTP.send
WebUploadDir f , baseUrl, usr, pwd
Next End Function
Function WebUploadFile (file, url, user, pass)
Dim objXMLHTTP
Dim objADOStream
Dim arrbuffer
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.LoadFromFile file
arrbuffer = objADOStream.Read()
Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
objXMLHTTP.open "PUT", url, False, user, pass
objXMLHTTP.send arrbuffer
End Function