Remove the time part from the full file path
Assuming that the full file path is stored within a variable named @[User::FilePath]
You have to add a variable of type string (example: @[User::Filename]
), Before the data flow task add an Expression Task
and use the following expression:
@[User::Filename] = SUBSTRING(@[User::FilePath], 1, LEN(@[User::FilePath]) -
FINDSTRING(REVERSE(@[User::FilePath]), "\\", 1)) + "\\" +
LEFT(TOKEN(@[User::FilePath],"\\",TOKENCOUNT(@[User::FilePath],"\\")),
LEN(TOKEN(@[User::FilePath],"\\",TOKENCOUNT(@[User::FilePath],"\\"))) - 10) + ".txt"
Example:
If the value of @[User::FilePath]
is
C:\New Folder\1\Filename_20190503001221.txt
Then @[User::Filename]
will be:
C:\New Folder\1\Filename_20190503.txt
If You have only the file name as
filename_20190503001221.txt
and the folder path is stored in another variable, just use the following expression:
@[User::Filename] = @[User::Folderpath] + "\\" +
LEFT(TOKEN(@[User::FilePath],"\\",TOKENCOUNT(@[User::FilePath],"\\")),
LEN(TOKEN(@[User::FilePath],"\\",TOKENCOUNT(@[User::FilePath],"\\"))) - 10) + ".txt"
Read File Source from Variable
Click on the flat file connection manager used to read the source file, press F4 to show the properties tab, Click on the expression property and assign the following expression to the connectionstring
property:
@[User::Filename]
Now change the Data Flow Task Delay validation
property value to True
.