• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 715
  • Last Modified:

ftp file copy dos batch script or VB6 code needed

I appreciate if someone can give me some sample code that will do the following.

Platform: windows 2003 server
1. log in to ftp
2. moves to a diffrent directory in the ftp
3. Moves all files to a local drive
   ( I want some code that loops through all the files  -  and also waits till all files are moved)
6. Log off ftp session

I beive I can pretty much do the logon logoff, bits but the copy files and the wait loops are the ones that I am not sure of.


  • 4
  • 2
2 Solutions
I would not recommend doing loops. Instead I'd say make it simple:

cd local directory (C:\..)
cd remote directory
get entire folder
cd local directory to also remote directory
delete the original file <-- this gets you the effect of moving the file.
log off
Manually writing the FTP commands in vb6 may be reinventing the wheel.  If you don't necessarily have to do it in VB6, try an existing app that has scripting, like WinSCP (http://winscp.net/eng/docs/scripting) or many others.  Here's another thread about this same topic: http://www.tek-tips.com/viewthread.cfm?qid=1231250&page=8

I actually have to do something similar for myself, so when I get it working, I'll post back my results.

I just found this reference to using WinSCP to sync a local folder with an remote folder:  http://winscp.net/eng/docs/script_commands#synchronize

That looks like it would work.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

indikadAuthor Commented:
can  or someone give me some sample code pls ?
Sure.  I'll be happy to connect the dots.  I haven't had a chance to put this into action for myself, but in my case, now that I found that WinSCP has good scripting capabilities and documentation, seeing the information I pointed out in an earlier post about the "synchronize" command (http://winscp.net/eng/docs/script_commands#synchronize), and knowing I'm not likely the first person to discover this, I Googled "winscp synchronize local".  I immediately found two excellent examples that I think are what you are looking for.  (I don't think it's necesary for me to copy and paste their code here, since they should get the attribution and credit for their efforts.)  Take a look at these two links:




Is that helpful?
I also should have mentioned that the first example is to backup from local to remote, and the second example is to backup from remote to local.
indikadAuthor Commented:
Thank you very much.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now