rename multiple files in ssis

how can i use SSIS to rename multiple txt file, such as
 i want to rename file1.txt to file1+systemDate.txt
                             file2.txt to file2+systemDate.txt
i know i will use foreachloop, but i still have porblem to set it up

thank
tristonyipAsked:
Who is Participating?
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.

Reza RadConsultant, TrainerCommented:
create new variable of datatype string in package scope, name it as FileName
create another variable of datatype string in package scope , name it as NewFileName


set a valid default value for FileName variable, this value should be physical file address which is valid.
set expression value of NewFileName variable as this:
SUBSTRING( @[User::FileName], 1 , LEN(@[User::FileName] ) - FINDSTRING(REVERSE( @[User::FileName] ),".",1) ) + (DT_WSTR, 4 )Year(GETDATE())+RIGHT("0"+(DT_WSTR, 2)Month(GETDATE()),2)+RIGHT("0"+(DT_WSTR, 2)Day(GETDATE()),2)+SUBSTRING( @[User::FileName], LEN(@[User::FileName] ) - FINDSTRING(REVERSE( @[User::FileName] ),".",1)+1 , FINDSTRING(REVERSE( @[User::FileName] ),".",1) )
and set EvaluateAsExpression property of this variable to True.

set a foreach loop with enumerator as file enumerator
and set source directory which contains files there.
set retrieve file name as Fully Qualified
in varaible mappings tab, set variable as user::FileName with index 0

then add a file system task inside foreach loop,
set operation as Rename file,
set source as varaible to true, and set source variable as User::FileName there.
set destination as variable to true, and set destination varaible as User::NewFileName there.


That's all.


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
vdr1620Commented:
Below is a Link to sample Package .. It moves and rename the File in one step (It moves and renames)


http://www.rafael-salas.com/2007/03/ssis-file-system-task-move-and-rename.html

http://www.sqlservercentral.com/Forums/Topic459991-148-1.aspx?Highlight=rename
tristonyipAuthor Commented:
i got it work, thanks a lot
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

From novice to tech pro — start learning today.