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?
Hello Friends,

I need a script on how to transfer files with TMP suffix . What i need is basically like this:

• PUTFILES from a local windows directory onto an remote FTP directory with suffix temp like: abc.tmp
• After successful transfer rename the file back to original file name: abc

Can someone send me this script?

Looking forward to you guys reply

Regards,
Hi there, ;)

ScriptFTP already uploads the files with a suffix but instead of using ".tmp" it uses ".part". Once the file has been completely uploaded the suffix is removed.

If using ".tmp" is mandatory in your case try doing the following:

[scriptftp="upload_and_rename.ftp"]# Connect to FTP server
OPENHOST("127.0.0.1","test","test")

# Uploads the files without the .part suffix
SETUPLOADMODE(DIRECT)

# Set the current local directory
LOCALCHDIR("C:\Users\Carlos\Desktop\test")

# Set the current remote directory (files will be uploaded there)
CHDIR("/")

# Upload myfile.txt as myfile.txt.tmp"
$result=PUTFILE2("myfile.txt","myfile.txt.tmp")

# If the file has been successfully uploaded remove the
# tmp suffix from the remote file name
IF($result=="OK")
RENAMEFILE("myfile.txt.tmp","myfile.txt")
END IF

CLOSEHOST[/ScriptFTP]


And if you need to upload multiple files:

[scriptftp="upload_and_rename_2.ftp"]# Connect to FTP server
OPENHOST("127.0.0.1","test","test")

# Uploads the files without the .part suffix
SETUPLOADMODE(DIRECT)

# Set the current local directory
LOCALCHDIR("C:\Users\Carlos\Desktop\test")

# Set the current remote directory (files will be uploaded there)
CHDIR("/")

# Get the list of local files
GETLIST($list,LOCAL_FILES)

# For each file in $list...
FOREACH $file IN $list

# Upload myfile.txt as myfile.txt.tmp"
$result=PUTFILE2($file,$file.".tmp")

# If the file has been successfully uploaded remove the
# tmp suffix from the remote file name
IF($result=="OK")
RENAMEFILE($file.".tmp",$file)
END IF
END FOREACH

CLOSEHOST[/ScriptFTP]