SSIS Expression to Get File Name From Full Path


RIGHT( @[User::FullPath] , FINDSTRING(REVERSE( @[User::FullPath] ) , "\\", 1) - 1)

Here is what it does:

  • Reverse the full path so the last backslash (\) becomes the first one.
  • Get the position of the first backslash in the reversed string and this way we would know the length of the file name.
  • Use the RIGHT() function get the file name since we know its length.
Advertisements

One thought on “SSIS Expression to Get File Name From Full Path

  1. This seems to work as long as the input string is in fact a full path. If just a filename, this breaks down.

    For cases where I don’t know if I am getting a full path OR a filename, I use:
    TOKEN(FileName, “\\”, TOKENCOUNT(FileName, “\\”))

    Which basically just grabs the last token, delimited by the backslash.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s