Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Small subroutine to create multiple Folder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBWin Small subroutine to create multiple Folder

    '###########################################################################
    ' Small subroutine to create multiple Folder and subfolder.
    ' Here is better, use it, or whatever you want
    ' excuse my bad English
    '###########################################################################
    ' Pequeña SubRutina para crear Folder y multiples subfolder .
    ' Aqui es mejorarlo , usarlo , o lo que quieras
    '###########################################################################
    ' "CrearSubFolder.bas"
    #COMPILER PBWIN 9 "CrearSubFolder.exe"


    #DIM ALL
    ' Limitation to use only slash \
    '$Via_Path = "C:\temp\Temp2\Temp3\Temp4\Temp5\" ' <- only slash -> '\'

    SUB Create_multi_folders (BYVAL Via_Path AS STRING)EXPORT
    LOCAL DRIVE ,FOLDER, MasFolder, a AS STRING
    LOCAL y,x AS LONG
    ''''''''''''''''''''''''''''''''''''''''''''''''
    'syntax:
    ' Path_Target = "C:\temp\Temp2\Temp3\Temp4\Temp5\"
    ''''''''''''''''''''''''''''''''''''''''''''''''
    A = RIGHT$(Via_Path,1)
    IF A<>"\" THEN MSGBOX "please add slash at the"+$CRLF+_
    " end of the Via_Path \",64,"Function->"+FUNCNAME$ :EXIT SUB
    x= TALLY (Via_Path , ANY "\")
    IF x>1 THEN 'presume there is a subdirectory or more
    FOR y = 1 TO x
    drive= PARSE$(Via_Path,ANY "\",1)+"\"
    folder = PARSE$(Via_Path,ANY "\",y+1)
    masfolder = masfolder+"\"+Folder
    IF folder<>"" THEN MKDIR drive+masfolder
    FILECOPY "crearsubfolder.bas", masfolder+"crearsubfolder.bas" '<--AutoCopy

    NEXT

    END IF
    END SUB


    FUNCTION PBMAIN () AS LONG

    LOCAL Via_Path AS STRING
    Via_Path = "C:\temp\Temp2\Temp3\Temp4\Temp5\"
    Create_multi_folders Via_Path
    MSGBOX "Folder and file were created",64,"Function->"+FUNCNAME$

    END FUNCTION
Working...
X