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:-
Thanks
Trevor
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
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
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
liked Script FTP? Try our other product Email Parser
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
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