Advertisement
djvj

Untitled

Feb 23rd, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. BuildAssetsTable(list,label,AssetType,extensions=""){
  2. Log("BuildAssetsTable - Started - Building Table for: " . label,4)
  3. Global logLevel
  4. StringReplace, extensions, extensions, |, `,,All
  5. obj:={}
  6. StringSplit, labelArray, label, |,
  7. StringSplit, AssetTypeArray, AssetType, |,
  8. Loop, Parse, list,|,
  9. {
  10. If !(labelArray%A_index% = "#disabled#")
  11. {
  12. Log("BuildAssetsTable - Searching for: " . A_LoopField,4)
  13. labelIndex++
  14. currentLabel := labelArray%labelIndex%
  15. currentAssetType := AssetTypeArray%A_index%
  16. RASHNDOCT := FileExist(A_LoopField)
  17. If InStr(RASHNDOCT, "D") { ; it is a folder
  18. folderName := A_LoopFileName
  19. Loop, % A_LoopField . "\*.*"
  20. { If A_LoopFileExt in %extensions%
  21. { currentobj := {}
  22. If (currentLabel="keepFileName")
  23. currentobj["Label"] := folderName
  24. Else
  25. currentobj["Label"] := currentLabel
  26. If obj[currentLabel].Label
  27. { currentobj := obj[currentLabel]
  28. currentobj.TotalItems := currentobj.TotalItems+1
  29. } Else {
  30. currentobj.TotalItems := 1
  31. obj.TotalLabels := if obj.TotalLabels ? obj.TotalLabels + 1 : 1
  32. obj[obj.TotalLabels] := currentobj.Label
  33. }
  34. currentobj["Path" . currentobj.TotalItems] := A_LoopFileLongPath
  35. currentobj["Ext" . currentobj.TotalItems] := A_LoopFileExt
  36. currentobj["AssetType"] := currentAssetType
  37. currentobj["Type"] := "ImageGroup"
  38. obj.Insert(currentobj["Label"], currentobj)
  39. }
  40. }
  41. } Else If InStr(RASHNDOCT, "A") { ; it is a file
  42. SplitPath, A_LoopField, , currentDir,, FileNameWithoutExtension
  43. Loop, Parse, extensions,`,,
  44. {
  45. If (InStr(extensions , ",") && A_Index >= 2) {
  46. labelIndex++ ; need to advance the label by one each time a new extension is used
  47. currentLabel := labelArray%labelIndex%
  48. }
  49. If FileExist(currentDir . "\" . FileNameWithoutExtension . "." . A_LoopField)
  50. { currentobj := {}
  51. If (currentLabel="keepFileName")
  52. currentobj["Label"] := FileNameWithoutExtension
  53. Else
  54. currentobj["Label"] := currentLabel
  55. If obj[FileNameWithoutExtension].Label
  56. { currentobj := obj[FileNameWithoutExtension]
  57. currentobj.TotalItems := currentobj.TotalItems+1
  58. } Else {
  59. currentobj.TotalItems := 1
  60. obj.TotalLabels := if obj.TotalLabels ? obj.TotalLabels + 1 : 1
  61. obj[obj.TotalLabels] := currentobj.Label
  62. }
  63. currentobj["Path" . currentobj.TotalItems] := currentDir . "\" . FileNameWithoutExtension . "." . A_LoopField
  64. currentobj["Ext" . currentobj.TotalItems] := A_LoopField
  65. currentobj["AssetType"] := currentAssetType
  66. obj.Insert(currentobj["Label"], currentobj)
  67. }
  68. }
  69. }
  70. }
  71. }
  72. If (logLevel>=5){
  73. for index, element in obj
  74. { Loop, % obj[element.Label].TotalItems
  75. mediaAssetsLog := % mediaAssetsLog . "`r`n`t`t`t`t`tAsset Label: " . element.Label . " | Asset Path" . a_index . ": " . element["Path" . a_index] . " | Asset Extension" . a_index . ": " . element["Ext" . a_index] . " | Asset Type" . a_index . ": " . element["AssetType"]
  76. }
  77. If mediaAssetsLog
  78. Log("BuildAssetsTable - Media assets found: " . mediaAssetsLog,5)
  79. }
  80. Log("BuildAssetsTable - Ended",4)
  81. Return obj
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement