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?
download all remote folders and subfolders to new local folder named to current date \yyyy.mm.dd and delete source files after.

Obviously not quite a programmer...
I might be asking too much but I have to try :)

Thank you
OK first of all thank you!

It creates the folder but than starts copying files out of the folder
Results in local folder look like this :
-\yyyy\mm\dd
-\copied folder 1
-\copied folder 2
etc.

Could I be doing something wrong ?
I'm sorry, the folder created, but not moved into it
FTP Script
  1. OPENHOST("ftp.myhost.com","myuser","mypassword")
  2. $RemotePath="/Remote_path"
  3. LOCALCHDIR("C:\dest_dir\")
  4. $CurDate=GETTIME(YEAR).".".GETTIME(MONTH).".".GETTIME(DAY)
  5. LOCALMKDIR($CurDate)
  6. LOCALCHDIR($CurDate)
  7. IF(GETFILE($RemotePath."/*.*", SUBDIRS)=="OK")
  8.   CHDIR($RemotePath)
  9.   DELETEFILE("*.*")
  10.   GETLIST($ListDir,REMOTE_DIRECTORIES)
  11.   FOREACH $Dir IN $ListDir
  12.     RMDIR($Dir)
seems to work fine now
thank you!

at times files copied or files deleted might be in use or just locked by windows.
can there be a skip command added for these files.

cuz if not.. it simply skips copying or deleting everything else :(
For a single directory easily. And if there are subdirectories, you have to check the directory structure and copy / delete each file separately. And this is a lazy ... ;)
The easy porobovat can be an option. We try to sync content MaxCtn time, if possible, then remove the content at the source. But if the files are widely used, the sense still will not ...
FTP Script
  1. OPENHOST("ftp.myhost.com","myuser","mypassword")
  2.  
  3. $RemotePath="/Remote_path"
  4. $LocalPath="\Local_path"
  5. $MaxCnt=10
  6.  
  7. LOCALCHDIR("$LocalPath")
  8. $CurDate=GETTIME(YEAR).".".GETTIME(MONTH).".".GETTIME(DAY)
  9. LOCALMKDIR($CurDate)
  10.  
  11. $Cnt=0
  12.  
  13. :SyncAgain
  14. $Result=SYNC($LocalPath."\".$CurDate, $RemotePath, DOWNLOAD, SUBDIRS)
  15. $Cnt=$Cnt+1
  16. IF(($Result!="OK") AND ($Cnt<$MaxCnt))
  17.   SLEEP(60)
  18.   GOTO :SyncAgain
  19.  
  20. IF($Result=="OK")
  21.   CHDIR($RemotePath)
  22.   DELETEFILE("*.*")
  23.   GETLIST($ListDir,REMOTE_DIRECTORIES)
  24.   FOREACH $Dir IN $ListDir
  25.     RMDIR($Dir)
  26.  
Thanks for helping Wandrey