SSIS variable for SQL Scheduled backup

Hi Experts,

I am working with SSIS to rename an SQL backup file.  The problem I am having is reading the most current file in the folder due to the format of the file name.  The current filename is: inetdispatchCAD_PEI_backup_2015_08_10_030001_3631355.bak.gpg.  This of course changes every backup, so i need to build an expression that will lookup the most current version of the files.  I will rename the file in order to decrypt it so that this inetdispatchCAD_PEI_backup_2015_08_10_030001_3631355.bak.gpg gets changed to this inetdispatchCAD_PEI_backup.bak.gpg.  Any help is greatly appreciated.

So Far I have this as a variable
"inetdispatchCAD_PEI_backup_" + (DT_WSTR,4)DATEPART("yyyy",GetDate()) + "_" +
RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + "_" +
RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + "_" +
RIGHT("0" + (DT_WSTR,2)DATEPART("HH",GetDate()),2) +
RIGHT("0" + (DT_WSTR,2)DATEPART("minute",GetDate()),2) +
RIGHT("0" + (DT_WSTR,2)DATEPART("ss",GetDate()),2) + "_" + ".bak" + ".gpg"

but it does not handle the ID of the file portion
Aaron GoodwinSenior Applications AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aaron GoodwinSenior Applications AnalystAuthor Commented:
I also tried following the instructions on this URL:

but I was still getting access denied errors
getmostrecentfile Error:the Remote server returned an error: (401) Unauthorized

i double checked the FTP address in the script, username and password...but It still does not work.

any ideas?
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I can't tell from memory whether the ID is fixed for that DB. If it is, you can just add it as a constant. Else you should use a batch file to determine the most recent backup file - you should anyway, because your var cannot be correct. The current date and time won't match the backup at any time.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aaron GoodwinSenior Applications AnalystAuthor Commented:
I ended up giving up on the FTP task within SSIS.  I used a powershell script to use winscp to get the most current file.  That works much better than the original track I was taking.  I was hoping to use all SSIS native tasks, but the powershell script was already written from the winscp it was easy to implement.  Thanks for the idea
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.