Link to home
Start Free TrialLog in
Avatar of theology
theology

asked on

VB Script create folder and copy data

Hi
I need to check via vb script that if folder exist do nothing if folder dose not exist create a folder and then copy all data from 9.4 folder to 9.4_AA
I am getting error on copyfolder
please suggest.



Set fso = CreateObject ("scripting.filesystemobject")
If Not fso.FolderExists( "D:\TAF\9.4_AA") Then
Set objFolder = fso.CreateFolder( "D:\TAF\9.4.2_AA")
End If
Set fso = CreateObject ("scripting.filesystemobject")
Set fso.copyfolder("D:\TAF\9.4","D:\HSCTAF\9.4_AA\")
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,
why did you create FSO two times?

Shouldnt it be more like
Set fso = CreateObject("scripting.filesystemobject")
If fso.FolderExists("D:\TAF\9.4_AA") = False Then
	Set objFolder = fso.CreateFolder("D:\TAF\9.4.2_AA")
	fso.copyfolder "D:\TAF\9.4","D:\HSCTAF\9.4_AA\" 
End If

Open in new window

And are you sure that the destination folder is
D:\HSCTAF\9.4_AA\
?

HTH
Rainer
ASKER CERTIFIED SOLUTION
Avatar of limweizhong
limweizhong
Flag of Singapore image

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