Solved

FTP script to transfer and combine, then delete

Posted on 2006-11-08
9
320 Views
Last Modified: 2012-06-21
Hi.
I have tried looking over the current solutions but not finding anything that is sutible, or that i understand :-)

I want to transfer all files in a certain folder on one XP client machine, accross a network to certain folder on another client machine (CSV files), then delete the originals. As an added bonus, i would like to then merge them all into a single text file but i would like this to be detailed seperatly as it is not definate that the merging is required at this stage.
The final script will need to be automated using scheduler or something.

I have found software that will do the tranfer and delete but would like the option of doing it via a script aswell.

Thanks in advance for any assistance.
Aidy.
0
Comment
Question by:Aidy_B
  • 6
  • 2
9 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17902789
How about this.  Copy all csv files to the specified unc path to another machine.  The /y wil overwrite any of the same name already there.  Then check if it errored during the copying and if so prompt with the error otherwise carry on and delete the CSV files.

@echo off
xcopy C:\folder\*.csv \\otherpc\share\folder /y

if errorlevel 1 echo Error %errorlevel% copying datat & pause & goto end

del c:\folder\*.csv

:end

To combine them all you can use

copy c:\folder\*.csv \\otherpc\share\folder\combined.csv

hth

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17904322
Read the question, missed the FP bit in the title... are you after something to work across a LAN as already shown or is it an FTP server you are wanting to transfer too?
0
 
LVL 10

Expert Comment

by:For-Soft
ID: 17904742
I do not think the FTP protocol is capable of merging files. It will be necesary to merge files on local computer, then to send the result through FTP, I believe.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 17905288
Agreed.... Aidy_B:  Let us know if this is to run on your local LAN asper above batch file or to a remote FTP server and if you want the merge way or individual files, pretty well it would be a script as follows:

Save between the lines as ftpscript.txt:
----------------------------
open yourftpserver
user username
password
cd /destfolder
lcd c:\sourcefolder
bin
mput *.csv
quit
----------------------------

and run it with this in a batch file or at command line

ftp -s:ftpscript.txt

To merge first do

@echo off
copy c:\folder\*.csv bigfile.csv
ftp -s:ftpscript.txt

and replace the mput command in the script with put bigfile.csv

Steve
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:Aidy_B
ID: 17909859
hi.
thanks for the input so far. the setup is a computer (pc1 for ease of clarity) on a company lan with the files being dumped into a set folder every so often automatically, but also networked on a seperate lan to another pc (pc2) which requires the previously mentioned files to be transferred every half hour or so, from pc1 to a set folder in pc2. the merging can be done either before or after the transfer but as i mentioned earlier, the merge bit is up for discussion at the moment so is not definately required and as such needs to be seperated out in any examples given.
with regard to the scripts given already, i will try them out in the next day or so when at work.
thanks again for any help given on this one.

aidy.  
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17910335
OK, let us know results of testing and any more detail on what is required and will help more.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17941723
Looking at ftp.exe for another issue today I notice there IS an append command so I guess it would be possible to append the CSV files using just FTP but it would need each file specified in a list rather than a wildcard.  Any good with the testing yet?
0
 

Author Comment

by:Aidy_B
ID: 17941857
hi.
sorry for the delay but being hit with loads of issues at the same time. this will be concluded in the next week or so.
cheers, aidy.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 18057036
Thanks for the answer, guess it worked ok then.

Steve
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now