Recursive folder creation

Sannyasin Brahmanathaswami brahma at hindu.org
Mon Aug 7 15:57:37 EDT 2017


I just came to this myself before  coming back here

put item -1 of pURL into tFile
   put item 1 to -2 of pURL into tFolder
   put tDF &"/" & tFolder into tCompletePath 
   
   # loop to create sub folders
   # Of course we know tDF exists, 
   # but we don't know about any folder after that
   
   repeat for each item x in tFolder
      put "/" & x after tNextFolder
            put tDF & tNextFolder into tSubFolder
      if there is not a folder tSubFolder then
         create folder tSubFolder
         put the result
      end if 
   end repeat  
   
   return tCompletePath &"/" & tFile

but your function is better

BR


 

On 8/7/17, 8:41 AM, "use-livecode on behalf of Tore Nilsen via use-livecode" <use-livecode-bounces at lists.runrev.com on behalf of use-livecode at lists.runrev.com> wrote:

    Since we do not need to check whether a folder exists or not before creating it as LiveCode will not create duplicate folders, here is a script that will create nested folders:
    
    on mouseUp
       put  specialFolderPath("desktop")& "/testFolder/testOne/test/result" into tFolder
       set the itemDel to "/"
       repeat with i = 1 to the number of items of tFolder
          put item 1 to i of tFolder into tFolderToCreate
          create folder tFolderToCreate
       end repeat
    end mouseUp
    
    Regards
    Tore



More information about the Use-livecode mailing list