Retrieve Part of the Filename stored in a variable

  • Hi

    I am using a Foreach loop container and in the derived column im trying to retrieve only the Filename but when I use the variable which actualy stores the Filename I also get the path of the File For example If a use a variable in the derived column expression I get the following Output C:\Data\Loop\Filesame.xls but I only need the file name i.e., name... How do i do that .. I have tried using Name only option in the For each Enumerator but it gives me error asking me to check if the Worksheet Name [Excel Source [122]] Error: Opening a rowset for "New$" failed. Check that the object exists in the database.

  • Hey Danny,

    one way to get the file name only would be to create another variable. set it's property, EvaluateAsExpression to True. Then enter the following expression:

    REVERSE(SUBSTRING( REVERSE(@[User::filename]),1, FINDSTRING( REVERSE(@[User::filename]) , "\\", 1 ) -1))

    replace the @[User::filename] variable in the sample code with your variable that is being populated by the ForEachFile loop.

    ArkWare

  • Thanks a lot dude!!!!

  • No Problem, Dude

    Expressions are your friend.. 😎

    ArkWare

Viewing 4 posts - 1 through 3 (of 3 total)

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