Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Move directories and files

Author  Topic 

FRANKMANIC
Starting Member

10 Posts

Posted - 2009-02-10 : 20:09:39
Hi, Can someone provide some idea on the task/process that would be required to move folders and all its files to another area.
We have a process that will place files in dated directories, it may have one day or multiple days worth of data.

Example: data is paced here
\\shared storage\FTPextracts
2008-02-06
file1.txt
file2.txt
file3.txt
2009-02-07
file1.txt
file2.txt
file3.txt

after processing filrd need to be moved to:

\\share storage\FTPextracts_archive
2008-02-06
file1.txt
file2.txt
file3.txt
2009-02-07
file1.txt
file2.txt
file3.txt


I'm assuming I can use the file task but do i need to place it in a for each loop to traverse the sub-folders- if so can I get an idea of the general flow of how it should be constructed. Thanks in advance!!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-02-10 : 20:17:48
I don't get fancy with SSIS packages, so I'd handle a task like this via the xcopy command or via a VBScript. I'm sure there's a more elegant way to do it in SSIS, but I like to stick with the basics.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-10 : 20:47:17
Use FILE SYSTEM TASK in SSIS to move directories. It is pretty easy.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-11 : 11:26:58
You dont have to loop through each folder and copy the files. Like Sodeep said, you can use a File System Task and copy/move the entire directory. If you dont want everything form the directory to be copied, you may have to set up separate file system tasks for copy on each sub folder.

Go to Top of Page

FRANKMANIC
Starting Member

10 Posts

Posted - 2009-02-11 : 17:52:53
thanks, I'm assuming that even though the date folder name will change daily that once I set up the file task properly it will move the folder and files? is this correct? or do I have to specify the name of the folder for each move?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-12 : 11:01:21
If you are doing a whole directory move/copy , you dont have to specify the names of folders within. It will work on whatever folders are within even if it changes everyday.
Go to Top of Page

FRANKMANIC
Starting Member

10 Posts

Posted - 2009-02-12 : 12:42:17
thank, what if i just wanted to move the folders and files from one directory to another? would i then need to travierse throught teh directory to get the unique folder name and then move?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-12 : 13:53:04
If you want to move only specific folders, you will have work on them individually. If you want to move ALL files/folders within the directory , then you can use the move/copy directory option in File System Task
Go to Top of Page

FRANKMANIC
Starting Member

10 Posts

Posted - 2009-02-17 : 09:38:44
Hi, after reviewing we only want to copy the folders and files - have some questions:
1. if the entire directory is copied does it delete all existing folders/files in the archive directory? or does it append the new folder/files?

2. If i need to move each subfolder with it's files - what is the work flow and tasks needed to accomplish this?

could i have some idea of what i need to do. Thanks in advance.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-17 : 13:44:39
For your first point, When you do a copy of a directory , it will replace the existing directory with the same name as source. Same as you do a 'copy' in windows.

Second point, I'll tell you what I know, not sure if its the best way.
For each folder, create a separate file syatem task, and do a copy directory to your destination. You will have to create one file system task for each folder that you copy.
Go to Top of Page
   

- Advertisement -