all groups > sql server dts > august 2007 >
You're in the

sql server dts

group:

Deleting only text files in a folder


Deleting only text files in a folder qjlee
8/29/2007 7:16:03 AM
sql server dts:
Hi, I have a folder located in C:\test. In the folder, there are lot of text
file and word document.

Is there a way I can create a file system task to delete the text file only?

Re: Deleting only text files in a folder Gerald Aichholzer
8/29/2007 4:29:57 PM
Hi,

[quoted text, click to view]

use the foreach-loop-container to loop over all text files and
put a file system task inside. In [1] you'll find some help on
the foreach-loop-container.

HTH,
Gerald

[1] SSIS: Enumerating files in a Foreach loop
Re: Deleting only text files in a folder Icon
9/10/2007 12:08:05 PM
[quoted text, click to view]

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()
dim filesys, demofile, myfolder
myfolder = "C:/"

set filesys = CreateObject ("Scripting.FileSystemObject")
set demofile = filesys.CreateTextFile (cSTR(myfolder) + "*.txt",
true)
set demofile = filesys.GetFile(cSTR(myfolder) + "*.txt")
demofile.Delete

Main = DTSTaskExecResult_Success
End Function
AddThis Social Bookmark Button