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 there,

I will post here an interesting question an user have sent via the contact form of this website. He/She forgot to fill the reply address field. Hopefully, he/she will find the reply here:
I have it running a ftp script that copies from a handheld dictaphone now to my ftp server. Then it deletes all the files after it has finished. My problem is that the file have to have a lower case extension on them on the server. They are WMA files. The recorder saves them as capitol letters only. I need them to ftp to my server as lower case. I don\'t care about the actual filename being in lower case but the extension has to be.

Example = VN20135.WMA is what is on the recorder. I need it to ftp to the server and change to VN20135.wma or vn20135.wma
FTP Script
  1. # Connect to the FTP server
  2. OPENHOST("ftp.serverremovedforprivacy.org","usernameremovedforprivacy","XXXXXXX")
  3.  
  4. # Change working directory to e:\\dss_flda\\
  5. LOCALCHDIR("e:\dss_flda")
  6.  
  7. # Retrieve the e:\\dss_flda\\ file listing
  8. $result=GETLIST($list,LOCAL_FILES,"*.wma")
  9.  
  10. # If GETLIST failed stop the script
  11. IF($result!="OK")
  12.        STOP
  13.  
  14. # For each file in $list...
  15. FOREACH $item IN $list
  16.        # Upload the file
  17.        $result=PUTFILE($item)
  18.        # If the file has been succesfully uploaded
  19.        # delete the local copy of the file
  20.        IF($result=="OK")
  21.                EXEC("del ".$item)
  22.        END IF
  23.  
  24.  
Well, the answer for this is to use TEXTCUT and TEXTLENGH for replacing the extension of a given file:
FTP Script
  1. FOREACH $item IN $list
  2.        # Upload the file
  3.       $item_lenght=TEXTLENGTH($item)
  4.       $item_upcased=TEXTCUT($item,1,$item_lenght-3)."WMA"
  5.        $result=PUTFILE($item_upcased)
  6.        # If the file has been succesfully uploaded
  7.        # delete the local copy of the file
  8.        IF($result=="OK")
  9.                EXEC("del ".$item)
  10.        END IF