File system Task -Delete Directory Content
This delete's the directory content as well as sub directory content! Is their a way i can just set it to delete the files in the said directory and not sub directories?
July 25th, 2007 11:20am

Do you mean the FIle System Task? File System Object was a feature of WSH and used a lot in DTS, not SSIS.
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2007 1:54pm

Yes i do mean the file system task in ssis. It has an option to delete directory content that deletes subdirevtory content as well. I just want to delete the files in the directory and not the sub directory. Can this task do this or do i have to revert to writing script using the File System Object to do this?
July 25th, 2007 6:03pm

You could use a For Each Loop to iterate the files in the directory and then the File System Task to delete them individually.
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2007 6:06pm

Mike Tomkies wrote: Yes i do mean the file system task in ssis. It has an option to delete directory content that deletes subdirevtory content as well. I just want to delete the files in the directory and not the sub directory. Can this task do this or do i have to revert to writing script using the File System Object to do this?Use a foreach loop to spin through the directory of your choosing. This will allow you to use a wildcard to get at the files you are specifically interested in deleting (even if it's *.*). Then inside the foreach loop, use a File System Task set to "Delete File". Pass in the file name from the foreach loop and you should be set.
July 25th, 2007 6:08pm

This for each loo how will it read the file names to pass to the task to delete?
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2007 6:10pm

Mike Tomkies wrote: This for each loo how will it read the file names to pass to the task to delete?It's built to do that. Click on the Collection tab and the enumerator should be set to "Foreach File Enumerator". From here, just give it a base directory and let it go to work.
July 25th, 2007 6:11pm

Thanks that is what i need.
Free Windows Admin Tool Kit Click here and download it now
July 25th, 2007 6:14pm

Think it would of been easy if The File system Task had the Traverse SubFolders option as in the ForEachLoop Container.
July 25th, 2007 6:21pm

Here is a link to VBScript code that deletes files in a specific directory and uses regular expressions for name matches. Hope This help you or others. http://www.code-bytes.com/Automate_WSH_VBScript_To_Delete_Or_Archive_Files.html
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 12:41am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics