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 everyone, I would like to create a script that allows me to create folder of a .zip file in my remote ftp server. Example:

in this path C: //test / I have several .zip files (test1.zip, test2.zip .....) I would like to automatically send these files by creating the test1 folder and uploading the test1.zip files and so on, you have some code to do this please? Thanks so much
Dropping test for errors, taking the length of the file extension is equal to three, hoping the lack of points in the file name will be something like this:
FTP Script
  1. OPENHOST("ftp.myhost.com","joe","123456")
  2.  
  3. LOCALCHDIR("C:\Test")
  4.  
  5. GETLIST($list, LOCAL_FILES)
  6.  
  7. FOREACH $item IN $list
  8.     $dir = "/".TEXTCUT($item, 1, TEXTLENGTH($item) - 4)
  9.     MKDIR($dir)
  10.     CHDIR($dir)
  11.     PUTFILE($item)
  12.  
Sorry for my English, I use Google translator.
Thank you so much for helping me, this would be the script to be included in the right program?
One last question: I would like to connect to my FTP server with SSL (Auth SSL) and port 2121, you know how to do this please?

Once you send files and can put in the script the ability to delete files that sent to the server? Thanks so much
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  2. SETPORT(2121)
  3. OPENHOST("ftp.myhost.com", "joe", "123456")
  4.  
  5. $localdir = "C:\Test"
  6. LOCALCHDIR($localdir)
  7.  
  8. GETLIST($list, LOCAL_FILES)
  9. FOREACH $item IN $list
  10.   $dir = "/".TEXTCUT($item, 1, TEXTLENGTH($item) - 4)
  11.   MKDIR($dir)
  12.   CHDIR($dir)
  13.   $result = PUTFILE($item)
  14.   IF $result == "OK"
  15.    EXEC ("del /f /q ".$localdir."\".$item)
  16.   END IF
  17.  
Thanks so much, I tried the script but when I start telling me these errors.
····· Script syntax error on line 14, column 21
····· "(" Expected ")" expected
I wanted to ask, my server requires an SSL certificate, how can I integrate it in the script? Thanks so much
[ScriptFTP]IF ($result == "OK")[/ScriptFTP]
Wow, now it works without errors.

If I wanted to send the file to the local folder, for example remote server in the test1 folder on my server, what should I be scripted? Thank you
Thank you so much for your help, it all works perfectly. One last question, how come the speed of upload and only 1000 kb / s, there is a system to increase it? Thank you
And if the upload/download files, for example, via IE, higher speed?
Yes, right, my speed connection is 200 mbps, thanks for helping me
No matter what connection speed. Download speed in Internet Explorer from this server higher than scriptftp?
Is accurate, and much faster than IE, instead by ScriptFTP speed reaches up to 1000 kb / s, do not understand why, thanks
Hello and thank you for helping me with the script, could you please help again with the script? If I have several files in the directory called test1.part1, test1.part2 and so on, when it sends the files to the server I would do so creates the folder with the name excluding part1 and obviously must send all matching files (test1.part2. test1.part3) inside the folder with all files to be sent every time there are new files and then i would make sure that ends before all the files and then sends the new. I hope you understand what I mean. Thanks so much
Something like this:
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  2. SETPORT(2121)
  3. OPENHOST("ftpserver1.host.com", "user", "password")
  4.  
  5. $localdir = "C:\Test"
  6. $remotedir = "/GAME-PC"
  7. LOCALCHDIR($localdir)
  8.  
  9. GETLIST($list, LOCAL_FILES)
  10.  
  11. WHILE (COUNTELEMENTS($list) > 0)
  12.   $length = TEXTLENGTH($list)
  13.   $i = 1
  14.   WHILE ((TEXTCUT($list, $i, 1) != '|') AND ($i <= $length))
  15.     $i = $i+1
  16.   $item = TEXTCUT($list, 1, $i-1)
  17.  
  18.   $length = TEXTLENGTH($item)
  19.   $i = 1
  20.   WHILE ((TEXTCUT($item, $i, 1) != '.') AND ($i <= $length))
  21.     $i = $i+1
  22.   $name = TEXTCUT($item, 1, $i-1)
  23.  
  24.   CHDIR($remotedir)
  25.   MKDIR($name)
  26.   CHDIR($name)
  27.   $result = PUTFILE($name.".*")
  28.   IF ($result == "OK")
  29.     EXEC ("del /f /q ".$localdir."\".$name.".*")
  30.   END IF
  31.  
  32.   GETLIST($list, LOCAL_FILES)
  33.  
Remember, in this script error checking is minimal. And possible infinite loop if the files are not deleted ...
Sorry for my English, I am using Google translator.
Few optimizations...
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  2. SETPORT(2121)
  3. OPENHOST("ftpserver1.host.com", "user", "password")
  4.  
  5. $localdir = "C:\Test"
  6. $remotedir = "/GAME-PC"
  7. LOCALCHDIR($localdir)
  8.  
  9. GETLIST($list, LOCAL_FILES)
  10.  
  11. WHILE (COUNTELEMENTS($list) > 0)
  12.   $length = TEXTLENGTH($list)
  13.   $i = 1
  14.   WHILE ((TEXTCUT($list, $i, 1) != '.') AND (TEXTCUT($list, $i, 1) != '|') AND ($i <= $length))
  15.     $i = $i+1
  16.   $name = TEXTCUT($list, 1, $i-1)
  17.  
  18.   CHDIR($remotedir)
  19.   MKDIR($name)
  20.   CHDIR($name)
  21.   $result = PUTFILE($name.".*")
  22.   IF ($result == "OK")
  23.     EXEC ("del /f /q ".$localdir."\".$name.".*")
  24.   END IF
  25.  
  26.   GETLIST($list, LOCAL_FILES)
  27.  
Hello Friend, thanks for the help, but I have a problem, unfortunately, when I only have a file (not divided into parts) does not send error saying, I also noticed that if the file is divided into several parts, as the.best. 2017.part1, part2, and so on, it just creates the first part of the name at the remote location, in this case 'the', then I would do so when the individual files located only send them without problems, and when they are in several parts sends to the server, thank you so much
Well, I warned about the lack of dot in the file name. The script does not alter the problem that you do with FTP server that does not understand the dot in the file name?
FTP Script
  1. SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  2. SETPORT(2121)
  3. OPENHOST("ftpserver1.host.com", "user", "password")
  4.  
  5. $localdir = "C:\Test"
  6. $remotedir = "/GAME-PC"
  7. LOCALCHDIR($localdir)
  8.  
  9. GETLIST($list, LOCAL_FILES)
  10.  
  11. WHILE (COUNTELEMENTS($list) > 0)
  12.   $length = TEXTLENGTH($list)
  13.   $i = 1
  14.   WHILE ((TEXTCUT($list, $i, 1) != '|') AND ($i <= $length))
  15.     $i = $i+1
  16.   $item = TEXTCUT($list, 1, $i-1)
  17.  
  18.   $i = TEXTLENGTH($item)
  19.   WHILE ((TEXTCUT($item, $i, 1) != '.') AND ($i > 1))
  20.     $i = $i-1
  21.   $name = TEXTCUT($item, 1, $i-1)
  22.  
  23.   CHDIR($remotedir)
  24.   MKDIR($name)
  25.   CHDIR($name)
  26.   $result = PUTFILE($name.".*")
  27.   IF ($result == "OK")
  28.     EXEC ("del /f /q ".$localdir."\".$name.".*")
  29.   END IF
  30.  
  31.   GETLIST($list, LOCAL_FILES)
  32.  
The problem that sometimes does not create all the full name of the file but only a part. I hope to resolve. Thank you