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?
Is there a way to only upload a file if it doesn't already exist on the server? I don't want to overwrite an existing file because it means the application on the server hasn't yet processed the previous upload.

I don't know the name of the file in advance.

Ideally, it would be an option on SYNC that would only upload new files, but I haven't seen such a thing. Any suggestions would be appreciated.
You might want to use the GETLIST() command to return a list of remote files, loop through the list, and if the file does not exist, then perform your upload. Here's the algorithm:
FTP Script
  1. OPENHOST("ftp.myhost.com","myUsername","myPassword")
  2.  
  3. GETLIST($list,REMOTE_FILES,"*.*")
  4.  
  5. FOREACH $item IN $list
  6.        IF ($item == "The_File_I_Am_Looking_For.txt")
  7.               STOP
  8.        END IF
  9.  
  10. PUTFILE("The_File_I_Am_Looking_For.txt")
  11.  
to johnhom
I don't know the name of the file in advance.
Ideally, it would be an option on SYNC that would only upload new files, but I haven't seen such a thing.
to Frankdl
FTP Script
  1. OPENHOST("ftp.myhost.com","myuser","mypassword")
  2.  
  3. LOCALCHDIR("local_dir")
  4. CHDIR("remote_dir")
  5.  
  6. GETLIST($list, REMOTE_FILES, "*.*")
  7.  
  8.  
  9. FOREACH $item IN $list
  10.   ADDEXCLUSION(UPLOAD, $item)
  11.  
  12. SYNC("local_dir", "remote_dir", UPLOAD)
  13.  
to ScriptFTP support, in the documentation section in a tree of a table of contents is absent a direct reference at a command FOREACH.
Excuse for my English, I use the machine translator.
FOREACH is explained at Documentation->Getting started->Handling file lists

But someone looking for information about FOREACH will not find it easily, you are right. I've just updated the title of that help topic to "FOREACH. Handling file lists"

Thanks everybody for the contributions to the forum.