I am looking to achieve the following:
1) Copy a folder maintaining the file structure of the source
2) Copy only certain extensions like *.doc and *.xls
Now I have two ways I've been trying this, WMI:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("SELECT * FROM CIM_DataFile WHERE Extension = 'doc' AND Path = '\\Test\\Start\\'")
For Each objFile in colFiles
'this isn't worked out yet...
wscript.echo objfile.name
strCopy = "C:\test\" & objFile.FileName _
& "." & objFile.Extension
objFile.Copy(strCopy)
Next
and by using FSO:
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFolder "c:\Test\Start\*.doc\", "c:\Test\Finish"
I want to use WMI but I can't get it to go into the subdirectories AND I'm not sure how to recreate the directory structure at the destination. FSO gives me the structure, but without WMI Query, I can't look for only the file types I want...
Is this making any sense??? HEEEEELLLLLLPPP!
1) Copy a folder maintaining the file structure of the source
2) Copy only certain extensions like *.doc and *.xls
Now I have two ways I've been trying this, WMI:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("SELECT * FROM CIM_DataFile WHERE Extension = 'doc' AND Path = '\\Test\\Start\\'")
For Each objFile in colFiles
'this isn't worked out yet...
wscript.echo objfile.name
strCopy = "C:\test\" & objFile.FileName _
& "." & objFile.Extension
objFile.Copy(strCopy)
Next
and by using FSO:
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CopyFolder "c:\Test\Start\*.doc\", "c:\Test\Finish"
I want to use WMI but I can't get it to go into the subdirectories AND I'm not sure how to recreate the directory structure at the destination. FSO gives me the structure, but without WMI Query, I can't look for only the file types I want...
Is this making any sense??? HEEEEELLLLLLPPP!