beanBlog

Auto FTP Download, Upload, and Batch file

Posted by: thebeanproject on: June 19, 2009

Last month, I was told to create a script that will download files automatically from the server and upload it to another server. I was having a hard time on how to figure this out. Fortunately, I ran across Auto FTP Manager. This program allows you to connect to any FTP server and automatically upload and download files or synchronize directories. Since every week they have different filenames on the downloaded files, so I have to create a Batch file that will get files from the download directory and rename it according to the filenames on the other webserver. Below is the batch file that I created and saved it as runit.bat.

@ECHO OFF

set totcount=0

for /f “usebackq delims=” %%a in (`dir /b *.pdf`) DO (
call :s_do_sums “%%a”
)

:s_do_sums
set /a totcount+=1
IF EXIST %totcount%.pdf (
DEL %*
)
REN %* %totcount%.pdf

Using Auto FTP Manager you could schedule and automate your file transfers. Therefore, I used a scheduled task to run my batch file one hour after the scheduled ftp download is ran. After that I scheduled another ftp upload to another server in one hour timespan as well.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.