?
Solved

FTP script to transfer and combine, then delete

Posted on 2006-11-08
9
Medium Priority
?
360 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
[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
  • 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 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