0

I have a requirement where the output file needs to be saved(dynamically) with the naming convention as FileName_YYY-MM-DD_FileNumber where file number is the sequence number. For example:-

     ABC_2009-01-01_001  
     ABC_2009-01-01_002
     ABC_2009-01-01_003 and so on

I am able to get the name part and date part using expression in .TXT connection but unable to get the sequence number part. I would appreciate if anyone could help me out with the solution.

Thanks in advance!

mehtat_90
  • 586
  • 9
  • 29

1 Answers1

0

Use a package variable that starts with "1" and add one to it for each new file.

EDIT: To populate the variable, one way is to use a script task that opens a filesystemobject and gets all the file names in the folder, parses them and figures out what is the highest sequence number. Then just add one to that number and set the value of the variable to that.

And no, I don't have any code handy that does that. You'll need to write it yourself.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52
  • Can you help me out with writing of variable? I believe variable must get the highest sequence number from a file and then add 1 to that number. If no files are present than by default it must be 0 – mehtat_90 Sep 07 '16 at 19:07
  • I don't understand what you mean by "writing of variable". What do you have so far? What are you stuck on? – Tab Alleman Sep 07 '16 at 19:09
  • I created a variable which saves the output file with a desired name in a desired location :- @[User::LOCN]+"ABCD"+ "_"+ (DT_WSTR, 30)(DT_DBDATE)GETDATE() +".txt"....................I am stuck with sequence number part – mehtat_90 Sep 07 '16 at 21:13