Help with reading files in subfolders

  • Hi,
    I am having mutiple subfolders in a folder .Each subfolder contains multiple files.I have to read two files(Names N1111,N2222) from these subfolders .
    My requirement is that after reading these two files from each subfolder i have to delete that particular subfolder.
    My problem is how i can track that from a particular folder i have read both the files so that i can delete it.
    I tried using foreach loop ,but could not find any solution.

    Please help.Its urgent

  • Are you using SSIS tasks or batch scripts?

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • SSIS package

  • quite difficult since we don't know what you have developed so far, but here is a good starting point on For loops when working with files.
    https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/

    Are your subfolders not static that they can be left and only content be cleared? (trying to establish the requirement to delete the folders)

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • Yes the requirement is that they will be deleted since new subfolders are added daily.

  • I am able to read files ,but how i will track that i have read my two files in the folder .

  • Your Loop will perform the required read/operation then delete the folder, you'll need to encapsulate foreach file into a foreach folder.
    http://microsoft-ssis.blogspot.com/2011/01/foreach-folder-enumerator.html

    Perfecting your variables will be crucial.

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • sunil88_pal88 - Tuesday, February 28, 2017 7:46 AM

    I am able to read files ,but how i will track that i have read my two files in the folder .

    After reading the files, I recommend moving them to a separate archive folder structure.

    Then (assuming that they were the only files in the folder) you can run a script task at the end of execution to remove all empty folders.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply