Solved

Monitor FTP Folder(s) and Download Files to Specific Local Folders

Posted on 2013-10-30
2
902 Views
Last Modified: 2013-11-21
Hey All -

I've got a project which I'm trying to script that I cannot get to work correctly.  I have a remote location which has a folder named "Complete" in which files are dumped to at random times.  Some files may go directly in the root and others into folders in the root.  Each of the files' names will be different and one of about 5 different of extensions

Remote Example:
- Complete/UbuntuLinux1.iso
- Complete/Mint1/LinuxMint.zip
- Complete/Windows/Windows7.rar

Currently, I log in a few times a day via FTP, select the files I want, download them to one of 5 local folders, then delete the rest of the crap.  What I'm trying to do is automate this
process.

I tried using SmartFTP to create schewdules, but couldn't find a way for it to monitor a remote FTP site for changes.

Below is what I would need it to do / rules:
- Monitor folder on remote FTP site (including it's child folders) for new files which end in 1 of 5 extensions (.zip, .rar, .iso, .img, & .bin)

- Examine the filename - if "linux" is anywhere in the filename, download to the local "Linux" Folder.  If "Windows", then download to the local "Windows" folder, and so on.

Local Example of same remote files:
- Linux\UbuntuLinux1.iso
- Linux\LinuxMint.zip
- Windows\Windows7.rar

Any ideas for applications or scripts that may help with this? Is it makes any difference, I can connect to the remote site using FTP, FTPS, HTTP, or HTTPS.

Last resort would be for it to monitor and download everything in a specific remote folder, then have a separate application sort it all out.  Any ideas on this would be helpful, too.

Thanks!
0
Comment
Question by:BzowK
[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
2 Comments
 
LVL 16

Accepted Solution

by:
AlexPace earned 500 total points
ID: 39613106
You could do this with Robo-FTP running a script as a Windows service... change the download folders on those first two lines and then the logon information on the 5th line.
SET windows_folder = "c:\download\windows"
SET linux_folder = "c:\download\linux"

:connect
FTPLOGON "ftp.new.com" /user="UserID" /pw="secret"
FTPCD "Complete"
IFERROR GOTO long_sleep

:loop
FTPGETREWIND
FTPGETFILE "*" /incldirs 
IFERROR= $ERROR_NO_FILE_FOUND GOTO long_sleep 
IFERROR GOTO short_sleep
SETRIGHT extension = %sitefile 4
IFSTRCMPI extension ".zip" GOTO extension_OK
IFSTRCMPI extension ".rar" GOTO extension_OK
IFSTRCMPI extension ".iso" GOTO extension_OK
IFSTRCMPI extension ".img" GOTO extension_OK
IFSTRCMPI extension ".bin" GOTO extension_OK
; if we reach this line the extenions is no good
FTPDELETE %sitefile
GOTO loop

:extension_OK
IFSUBSTRI %sitefile "linux" GOTO download_linux
IFSUBSTRI %sitefile "windows" GOTO download_windows
; if we reach this line the filename lacks linux or windows
FTPDELETE %sitefile
GOTO loop

:download_linux
WORKINGDIR linux_folder /create 
RCVFILE %sitefile /delete
IFERROR GOTO short_sleep
GOTO loop

:download_windows
WORKINGDIR windows_folder /create 
RCVFILE %sitefile /delete
IFERROR GOTO short_sleep
GOTO loop

:short_sleep
PAUSE /for=3  
FTPLOGOFF
GOTO connect 

:long_sleep
PAUSE /for=300  ; 300 seconds is 5 minutes
FTPLOGOFF
GOTO connect

Open in new window

Note: I havn't tested this so it is sure to have a couple of bugs.

Edit: to use FTPS append the following to the FTPLOGON line:
  /servertype=FTPS /trust=all
0
 

Author Closing Comment

by:BzowK
ID: 39666282
Was able to edit and add a few lines and it worked - Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
can't ssh to external IP 9 63
Alot of sessions on a PC is generated 3 84
Cannot join domain and UNC paths 9 54
qbutilities dll could not be found 27 34
Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

749 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