hexagon logo

Auto create folder script

So at my last shop we had a .bas file that would create folders. here is what i am doing.
What it used to do would create a folder for part number(if it didnt already exist) then each sub folder.

then i could use this same code in every program since it pulls in the part number, operation, serial, from a text file and assigns them a variable.






Parents
  • This is what I use currently. Path1=Part number path Path2= Job number folder

    Sub Main()
    
    Dim objFSO, objShell
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Dim objFile, objFolder As Object
    
    Set PCDApp=CreateObject("PCDLRN.Application")
    Set PCDPartProgram=PCDApp.ActivePartProgram
    Set PCDCommands=PCDPartProgram.Commands
    
    Set Pathname1=PCDPartProgram.GetVariableValue("PATH1")
    
    strPath1=Pathname1.StringValue
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If objFSO.FolderExists(strPath1) Then
    'Nothing
    Else
    Set objFile=objFSO.CreateFolder(strPath1)
    End If
    
    Set Pathname2=PCDPartProgram.GetVariableValue("PATH2")
    
    strPath2=Pathname2.StringValue
    
    If objFSO.FolderExists(strPath2) Then
    'Nothing
    Else
    Set objFile=objFSO.CreateFolder(strPath2)
    End If
    
    End Sub
Reply
  • This is what I use currently. Path1=Part number path Path2= Job number folder

    Sub Main()
    
    Dim objFSO, objShell
    Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval
    Dim objFile, objFolder As Object
    
    Set PCDApp=CreateObject("PCDLRN.Application")
    Set PCDPartProgram=PCDApp.ActivePartProgram
    Set PCDCommands=PCDPartProgram.Commands
    
    Set Pathname1=PCDPartProgram.GetVariableValue("PATH1")
    
    strPath1=Pathname1.StringValue
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    If objFSO.FolderExists(strPath1) Then
    'Nothing
    Else
    Set objFile=objFSO.CreateFolder(strPath1)
    End If
    
    Set Pathname2=PCDPartProgram.GetVariableValue("PATH2")
    
    strPath2=Pathname2.StringValue
    
    If objFSO.FolderExists(strPath2) Then
    'Nothing
    Else
    Set objFile=objFSO.CreateFolder(strPath2)
    End If
    
    End Sub
Children
No Data