Solved

Copying file from one server to another

Posted on 2014-02-22
7
237 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 56

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 56

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 56

Expert Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

735 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