On Error Resume Next
dim fso, write, start, writeTo
' Where to read from, where to write to
start = "assets"
writeTo = "src/Assets.as"
Set fso = CreateObject("Scripting.FileSystemObject")
Set write = fso.CreateTextFile(writeTo, True)
' Begin file
write.WriteLine("package")
write.WriteLine("{")
write.WriteLine(" public class Assets")
write.WriteLine(" {")
' Read files
readFolder("")
' Close
write.WriteLine(" }")
write.WriteLine("}")
write.Close
Function readFolder(name)
Dim folder, files, folders, list, count, listName, className, extension
Set folder = fso.GetFolder(start & "/" & name)
' Clean the list name
listName = UCase(name)
listName = Replace(listName, "/", "_")
listName = Replace(listName, "-", "_")
listName = Replace(listName, " ", "")
list = " public static const " & listName & ":Array = ["
count = 0
' For every file ...
For each file In folder.Files
' Clean the file name
className = Left(file.Name, Len(file.Name) - 4)
className = name & "_" & className
className = Replace(className, "/", "_")
className = Replace(className, " ", "")
className = Replace(className, "-", "_")
className = UCase(className)
' get the extension
extension = Right(file.Name, 3)
' Add it to the list (array of files from this folder)
If count = 0 Then
list = list & className
Else
list = list & ", " & className
End If
' Write this to the file
If extension = "oel" Or extension = "xml" Then
write.WriteLine(" [Embed(source='../" & start & "/" & name & "/" & file.Name&"', mimeType='application/octet-stream')] public static const " & className & ":Class;")
Else
write.WriteLine(" [Embed(source='../" & start & "/" & name & "/" & file.Name&"')] public static const " & className & ":Class;")
End If
count = count + 1
Next
' Write the list of files from the folder, if any files exist
If count > 1 Then
list = list & "];"
write.WriteLine(list)
End If
' Find all the subfolders, and read them
For each subfolder in folder.SubFolders
write.WriteLine("")
write.WriteLine(" /* --- " & subfolder.Name & " --- */")
' only add a / if the previous folder exists (not the root folder)
If name = "" Then
readFolder(subfolder.Name)
Else
readFolder(name&"/"&subfolder.Name)
End If
Next
End Function