ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
Hi There,

I am a newbie and about to purchase ScriptFTP and was wondering if you could possibly point me in the right direction for the following problem?

I am looking to create a script that can be called from a command line that will do the following:-
  • PUTFILES from a local windows directory F:\OUT onto an FTP site with a filename composed of AAANNNNNNN.tmp, example TRE6000032.tmp
  • After successful transfer rename the file to remove the .tmp extension, leaving TRE6000032 without any extension
  • Also after successful FTP transfer move the file locally into an archive directory on the local fileserver F:\OUT\archive
  • Calling the script from a command line via an external application
I have had a look at several forum posts and there are similar routines, but just need a little help in getting it right

Thanks

Trevor
Hi Trevor,

I've written this script following your step-by-step instructions. You need to add OPENHOST to connect to the FTP server at the top of the script and CLOSEHOST at the end.

[scriptftp="file_upload_rename.ftp"]# Change current local directory to F:\Out
LOCALCHDIR("F:\OUT")

# Get the list of local tmp files
GETLIST($local_file_list,LOCAL_FILES,"*.tmp")

# For each tmp file...
FOREACH $filename IN $local_file_list
# Upload the file
$result=PUTFILE($filename)

# If the upload was successful
IF($result=="OK")

# Move the local file to the archive folder
EXEC("move ".$filename." F:\OUT\archive")

# Calculate the new file name removing .tmp
$new_filename=TEXTCUT($filename,1,TEXTLENGTH($filename)-4)

# Rename the file just uploaded with the new file name
RENAMEFILE($filename,$new_filename)
END IF

END FOREACH[/ScriptFTP]

To call this script from the command line see the following help topic:

http://www.scriptftp.com/reference.php?go=topic430
Hi Support,

Many Thanks for your script!
With a few minor amendments it does exactly what I required!

ScriptFTP is a very versatile product which ticks all the boxes for me

I will arrange the purchase of the site license for the product

Thank you for your excellent support

Regards,

Trevor