comnetlimited
Technical User
Hi,
I am newbie to VBScript. Below is a VBScript I wrote in Notepad (is there a proper software to use to write VB Script so that syntax can be checked??) and then save as Clear Error Folders.vbs on my deskstop.
What I am tryin to achieve is to move ONLY files that has a size of 1 KB From My Error folder to Data Folder.
Shown below is my below is my script.
Note i use >= 1 (??? is 1 KB = 1 ) for testing purposes only, just to see if the script can work.
++++++++++++++++++++++++++++++++++++++++++++++++++
Sub ProcessFiles()
dim oFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Data = FSO.GetFolder("D:\Data")
Set Error = FSO.GetFolder("D:\Error")
For Each oFile In Error.Files
If oFile.size >= 1 then
FSO.MoveFile "D:\Error\" & (oFile.Name) , Data
End if
Next
End Sub
Call ProcessFiles
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
However, it comes up with an Error:
Script: C:\Documents and Settings\mnarewec.stcheadoffice\Desktop\Clear Error Folders.vbs
Line: 10
Char: 4
Error: File already exists
Code: 800A003A
Source: Microsoft VBScript runtime Error
But Honestly, there is no file(s) in folder D:\Data
Please somebody help.
Thank you in advance
I am newbie to VBScript. Below is a VBScript I wrote in Notepad (is there a proper software to use to write VB Script so that syntax can be checked??) and then save as Clear Error Folders.vbs on my deskstop.
What I am tryin to achieve is to move ONLY files that has a size of 1 KB From My Error folder to Data Folder.
Shown below is my below is my script.
Note i use >= 1 (??? is 1 KB = 1 ) for testing purposes only, just to see if the script can work.
++++++++++++++++++++++++++++++++++++++++++++++++++
Sub ProcessFiles()
dim oFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Data = FSO.GetFolder("D:\Data")
Set Error = FSO.GetFolder("D:\Error")
For Each oFile In Error.Files
If oFile.size >= 1 then
FSO.MoveFile "D:\Error\" & (oFile.Name) , Data
End if
Next
End Sub
Call ProcessFiles
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
However, it comes up with an Error:
Script: C:\Documents and Settings\mnarewec.stcheadoffice\Desktop\Clear Error Folders.vbs
Line: 10
Char: 4
Error: File already exists
Code: 800A003A
Source: Microsoft VBScript runtime Error
But Honestly, there is no file(s) in folder D:\Data
Please somebody help.
Thank you in advance