Solved

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

Posted on 2013-10-30
2
915 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

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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