Solved

Copying file from one server to another

Posted on 2014-02-22
7
239 Views
Last Modified: 2014-03-10
Hi,

 I have the names of file path in a MS SQL 2005 table in the following format:

Path Filename
Myfileserver\ABC  abc.txt
Myfileserver\DBC  dbc1.txt

etc

These can be dumped into a flat file called processfiles.txt residing on the SQL server, which would contain the following contents:
Myfileserver\ABC\abc.txt
Myfileserver\DBC\dbc1.txt

I wanted to write a batch script that will reside on a different server than the SQL server and will need to copy those files in the table and put them on a folder on the current server.

How do I accomplish this?
0
Comment
Question by:LuckyLucks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Don Thomson
ID: 39879668
something like this may work

for %%f in (Myfileserver\abc\*.txt) DO type %%f>>\\Otherfileserver\whateverfolder\processfiles.txt
do this for each folder
0
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39879710
Is there any reason you can't dump the content from the SQL server directly to a BAT file. In other words

copy Myfileserver\ABC\abc.txt \\otherserver\path\abc.txt
copy ...

Open in new window

0
 

Author Comment

by:LuckyLucks
ID: 39879809
The problem is Myfileserver\ABC and Myfileserver\DBC etc are dynamically produced in the table. So prior to this question, there is a button thats presses, stuff happens and the table containing the two folder locations is created. It could  be a different number and name of folders the next time around. Each folder also may have a different number of files in it each time. Hence, any hardcoding is not going to work.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 57

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 39880635
No, what I mean is, as I understand your setup some process is producing a file
These can be dumped into a flat file called processfiles.txt residing on the SQL server, which would contain the following contents:

If this process is producing a list of files that another process (bat file) must read then why not simply create the output of the first file as bat commands.

If the destination is dynamic then use parameters i.e.
Output to movefiles.bat
copy Myfileserver\ABC\abc.txt %1
...

Open in new window

And call from second bat file

\\sqlserver\pathtobatfile\movefiles.bat \\someotherserver\somefolder

Open in new window

0
 
LVL 14

Expert Comment

by:Don Thomson
ID: 39881032
Do the original files have to be deleted?
0
 

Author Comment

by:LuckyLucks
ID: 39887378
no originals have to be deleted
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39888031
@LuckyLucas - any response to my previous post?
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question