Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy folder and content using SQL Server TSQL.

Status
Not open for further replies.

EM1107

IS-IT--Management
Apr 24, 2002
153
CA
Good day Guys

I hope someone can help me on that one.
I am trying to copy documents that has the folder structure and document name stored in tables and the actual document is store on a document server.
I take the path and files name using TSQL and copy the files to a new location including the folder structure and rename the file to a more readable name.
I can use the OLE automation to copy the files but it does not create the folder structure.
I must create the structure in advance and this is not always known until you get the file location.

I have tried to create an xcopy command that I saved to a txt file but the xcopy always ask me if it is a file of a folder.
Xcopy does not seem to have a command to always specify it is a file or a directory.
If I answer the question it work but I have to do it for every documents. If I have few documents it is fine but if I have 1000's of files to copy it is rather annoying to have to press the value every time.
If I create a robocopy command it will do just that but it will not rename the file correctly.
Also not everyone has a copy of that old application.

Does anyone had to do this and would have a solution to copy the structure and specific files?
Let me know if I am not clear.
 
So, let’s say you have this in your table(s):
[pre]
Path File
W:\SomeFolder\Docs\City\ ABCD.docx
W:\SomeFolder\Excel\ XYZ.xlsx
W:\SomeFolder\Excel\Town\ KLMN.txt
[/pre]
And you want to copy and rename above files:
[pre]
Path File
Z:\FolderX\Documents\C\ ABCDx.docx
Z:\FolderX\Excels\ XYZx.xlsx
Z:\FolderX\Excels\Towns\ KLMNx.txt
[/pre]
And you may or may not have folder structure on Z:\ drive
So, in order to copy files, first you need to determine if folders exist on Z:\ drive, and if they do not exist, create them before you copy and rename files “to a more readable name”.

Am I getting it?


---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I'm curious. What is wrong with cross posting? So what if it is in two different places? I don't mean the question to be negative, I just wonder why that is part of the policy here.
 
FWIW, I think it's fine to post in multiple forums, where you're likely to reach different people. The annoying kind of cross-posting to me is posting in multiple sections of the same forum.

Tamar
 
Also, hardly ever the OP returns to the original thread here and states: ”This is the answer I’ve got at XYZ site and that solves my issue.” So, people here are left hanging...

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
My view is that it is okay to post in multiple forums, but if you do, tell each forum about the other posts. That way potential responders can check to see whether a good answer has already been provided, or even pass on trying to respond. If you want help, show some respect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top