Solved

FTP script to transfer and combine, then delete

Posted on 2006-11-08
9
337 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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
 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

832 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