Create FTP Folder Tree

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Create FTP Folder Tree

Post by kpassaur » Wed May 20, 2009 3:53 pm

I thought some may find this useful as it will create a file folder tree on an ftp site with MS. It assumes there is a subfolder of the root.

Let>ftpusername=
Let>ftppassword=
Let>ftpport=21

//local path is actually the path to be created on the ftp site

Let>localpath=ftp.edocfile.info/kpassaur/sam/ted/frank
Separate>%localpath%,/,ftparray
Let>sf=ftparray_count
Let>rootftp=ftparray_1
StringReplace>%localpath%,%rootftp%,ftpfolder

GoSub>FTPSUB

SRT>FTPSUB
FTPGetDirList>%rootftp%,%ftpusername%,%ftppassword%,%ftpport%,c:\temp\readme.txt,%ftpfolder%,D
IF>FTP_RESULT=Success
Goto>Haveftpdir
Endif
Let>cs=2
Let>subd=ftparray_%cs%
Let>testfolder=/%subd%
Label>startbuildfolders

FTPGetDirList>%rootftp%,%ftpusername%,%ftppassword%,%ftpport%,c:\temp\readme.txt,%testfolder%,D

IF>FTP_RESULT=Success
If>%testfolder%=%ftpfolder%
Goto>Haveftpdir
Endif
Let>cs=cs+1
If>%cs%>%sf%
MDL>cannot create ftp direcot0ry
Endif
Let>subd=ftparray_%cs%
Let>testfolder=%testfolder%/%subd%
Goto>startbuildfolders
Else
FTPMakeDir>ftp.edocfile.info,%ftpusername%,%ftppassword%,%ftpport%,%testfolder%
IF>FTP_RESULT=Success
Goto>startbuildfolders
Else
MDL>Cannot build Subdirectory
Endif
Endif
Label>Haveftpdir
END>FTPSUB

MDL>Finished

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts