March 30, 2005 at 3:00 am
hi,
I would like to use the DTS active x script to loop through a folder, check each file, if the file is 0kb, i need to grab the file name and export to .txt file as a list.
below is my sample code:
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolders = oFS.GetFolder("C:\Scripts")
Set oFiles = oFolders.Files
For Each oFile In oFiles
if oFile.Size = 0 then
MsgBox ("file size is " & oFile.Size)
end if
Next
Main = DTSTaskExecResult_Success
Set oFolders = Nothing
Set oFiles = Nothing
Set oFile = Nothing
Set oFS = Nothing
End Function
==========================================================
instead of showing Msgbox ("file size is " & oFile.Size) , i need to grab the file name which is 0kb to a .txt file.
how is it possible to do so?
thanks~
March 30, 2005 at 5:23 am
You will WRITELINE your oFile to a text file. There are plenty of sample scripts in VB BOL, and on the internet (to include decent from support.microsoft.com) with textstream, writeline, etc... with the FSO (filesystemobject)
Good Hunting!
AJ Ahrens
webmaster@kritter.net
March 31, 2005 at 1:01 am
Hi, I would suggest
http://www.devguru.com/Technologies/vbscript/quickref/vbscript_list.html
http://www.devguru.com/Technologies/vbscript/quickref/file.html
as a good online reference site, with examples ...
I use it all the time, almost as an online manual.
Happy coding,
H
March 31, 2005 at 2:02 am
Msgbox ("File name is " & oFile.Name)
April 5, 2005 at 3:42 am
Thanks All...
I will look into the sample code and shall revert to you all back should i have further enquiries.
Many thanks~
April 6, 2005 at 1:22 am
use the ofile.type = "text file" and check in the if condition.
if ofile.size=0 and ofile.type="text file"
This will suffice ur requirement.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply