' This is the path to the root directory with the .class files
Const SourceDir = "D:\myproject\bin" 
' This is the path to the directory where source file will be created
Const DestDir = "D:\myproject\src"
Const jadDir = "D:\jad\"
Const jadExe = "jad.exe"
Dim fcounter

Dim FilesArray(3000)
Dim FoldersArray(100)

Dim fileCounter


fcounter = 0
fileCounter = 0
ListFolderContents SourceDir

Final jadDir & jadExe, SourceDir, DestDir, jadDir & "decompile.bat"


MsgBox "The End"




Sub ListFolderContents(path)
    Dim str
    Dim File
     Set fs = CreateObject("Scripting.FileSystemObject")
     Set folder = fs.GetFolder(path)


        Set Files = folder.Files
        'Add files to files array
           For Each File In Files
            If LCase(Right(File.path, 5)) = "class" Then
              str = Right(File.path, Len(File.path) - Len(SourceDir))
            FilesArray(fileCounter) = str
                fileCounter = fileCounter + 1
            End If
            Next

    
         For Each Item In folder.SubFolders
            If Not LCase(Item.Name) = "cvs" Then
                str = Right(Item.path, Len(Item.path) - Len(SourceDir))
                FoldersArray(fcounter) = str
                fcounter = fcounter + 1
            End If
            ListFolderContents (Item.path)
         Next
    Set fs = Nothing
    Set folder = Nothing
End Sub


Sub Final(pjad, psourcedir, ptargetdir, Filename)
    Dim fso
    Dim Fl
    Dim counter
    Dim strtarget
    Dim strsource
    Dim j
    Dim str
    Dim temppath
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set tStr = fso.CreateTextFile(Filename, True)
    tStr.writeLine ("cls")

    'First create the directories

    For counter = 0 To fcounter - 1
        strtarget = ptargetdir & FoldersArray(counter)
        If Not fso.folderexists(strtarget) Then
            Set f = fso.CreateFolder(strtarget)
        End If
    Next


    For counter = 0 To fileCounter - 1
        'Get the path of the file
        temppath = Left(FilesArray(counter), InStrRev(FilesArray(counter), "\"))
        strtarget = ptargetdir & temppath
        strsource = psourcedir & FilesArray(counter)
        'Make target dir if it doesn't exist
        str = pjad & " " & "-sjava -d" & strtarget & " " & strsource
        tStr.writeLine (str)
    Next
    tStr.writeLine ("pause")
    tStr.Close
End Sub



