SQLTeam.com | Weblogs | Forums

Ssis package rename files

I have a rename SSIS package I need to create. I have the process down for moving files between folders, but I need to add a complication wherein I name the source file with data coming from my SQL server. Here's an example:

I have 5 files in a folder:


My system now knows how to pick up these individual file names and then assign them to the particular ORDER NUMBER that they belong to within SQL. The data looks something like this:

File Name Order Number

20150420031600.pdf A1234
20150420031610.pdf B5678
20150420031620.pdf C5548862-45684
20150420031630.pdf D445521-CG5-456654
20150420031640.pdf E12222354

Now I need a process that will rename the existing PDFs into their corresponding order numbers like this:

20150420031600.pdf would become A1234.pdf
20150420031610.pdf would become B5678.pdf
20150420031620.pdf would become C5548862-45684.pdf
20150420031630.pdf would become D445521-CG5-456654.pdf
20150420031640.pdf would become E12222354.pdf

Any ideas on how to perform this? I'm sure I'll need to just flow the data from the SQL tables into variables, but I'm not clear how to get rolling on this.

Thanks in advance!

get the FileName and OrderName into an object variable. Then in a foreach loop, get each filename and OrderName into local variables and pass into script task. In the script task, check to see if the filename exists and the New file name does not exist. If true, then use file.move to rename it.