Link to home
Create AccountLog in
Avatar of sqlagent007
sqlagent007Flag for United States of America

asked on

use an SSIS package to copy folders and rename them with FOLDER_YYYYMMDD

I have seen several examples online where people are using the SSIS for each loop container to move \ copy files from one destination to another, however I need to copy folders from our primary storage to second tier storage. Currently all the databases backup to a primary storage device that is mapped as the [G:] drive. I need to copy all the folders that contain the database backups with the .bak and .trn files to my secondary (cheaper) storage at a UNC path.
Is there a way to do this with SSIS?
Thanks experts!
Avatar of radcaesar
radcaesar
Flag of India image

Use Script task

Check the files in the folder using System.IO

If file exists in that folder move that using the method "File.Move(stcFileName, destFileName)"
ASKER CERTIFIED SOLUTION
Avatar of EvilPostIt
EvilPostIt
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
If folders which you want to copy and rename  has specified names you can simply use File System Task (  sometimes combined with Foreach Loop Container )
but if your folder names are not obvious, It is better to use Script task with System.IO classes.

I think this is better to tell us what you want to do exactly, with sample name of folders and we tell you right way.
Avatar of sqlagent007

ASKER

Thanks!