Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BuildAssetsTable(list,label,AssetType,extensions=""){
- Log("BuildAssetsTable - Started - Building Table for: " . label,4)
- Global logLevel
- StringReplace, extensions, extensions, |, `,,All
- obj:={}
- StringSplit, labelArray, label, |,
- StringSplit, AssetTypeArray, AssetType, |,
- Loop, Parse, list,|,
- {
- If !(labelArray%A_index% = "#disabled#")
- {
- Log("BuildAssetsTable - Searching for: " . A_LoopField,4)
- labelIndex++
- currentLabel := labelArray%labelIndex%
- currentAssetType := AssetTypeArray%A_index%
- RASHNDOCT := FileExist(A_LoopField)
- If InStr(RASHNDOCT, "D") { ; it is a folder
- folderName := A_LoopFileName
- Loop, % A_LoopField . "\*.*"
- { If A_LoopFileExt in %extensions%
- { currentobj := {}
- If (currentLabel="keepFileName")
- currentobj["Label"] := folderName
- Else
- currentobj["Label"] := currentLabel
- If obj[currentLabel].Label
- { currentobj := obj[currentLabel]
- currentobj.TotalItems := currentobj.TotalItems+1
- } Else {
- currentobj.TotalItems := 1
- obj.TotalLabels := if obj.TotalLabels ? obj.TotalLabels + 1 : 1
- obj[obj.TotalLabels] := currentobj.Label
- }
- currentobj["Path" . currentobj.TotalItems] := A_LoopFileLongPath
- currentobj["Ext" . currentobj.TotalItems] := A_LoopFileExt
- currentobj["AssetType"] := currentAssetType
- currentobj["Type"] := "ImageGroup"
- obj.Insert(currentobj["Label"], currentobj)
- }
- }
- } Else If InStr(RASHNDOCT, "A") { ; it is a file
- SplitPath, A_LoopField, , currentDir,, FileNameWithoutExtension
- Loop, Parse, extensions,`,,
- {
- If (InStr(extensions , ",") && A_Index >= 2) {
- labelIndex++ ; need to advance the label by one each time a new extension is used
- currentLabel := labelArray%labelIndex%
- }
- If FileExist(currentDir . "\" . FileNameWithoutExtension . "." . A_LoopField)
- { currentobj := {}
- If (currentLabel="keepFileName")
- currentobj["Label"] := FileNameWithoutExtension
- Else
- currentobj["Label"] := currentLabel
- If obj[FileNameWithoutExtension].Label
- { currentobj := obj[FileNameWithoutExtension]
- currentobj.TotalItems := currentobj.TotalItems+1
- } Else {
- currentobj.TotalItems := 1
- obj.TotalLabels := if obj.TotalLabels ? obj.TotalLabels + 1 : 1
- obj[obj.TotalLabels] := currentobj.Label
- }
- currentobj["Path" . currentobj.TotalItems] := currentDir . "\" . FileNameWithoutExtension . "." . A_LoopField
- currentobj["Ext" . currentobj.TotalItems] := A_LoopField
- currentobj["AssetType"] := currentAssetType
- obj.Insert(currentobj["Label"], currentobj)
- }
- }
- }
- }
- }
- If (logLevel>=5){
- for index, element in obj
- { Loop, % obj[element.Label].TotalItems
- 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"]
- }
- If mediaAssetsLog
- Log("BuildAssetsTable - Media assets found: " . mediaAssetsLog,5)
- }
- Log("BuildAssetsTable - Ended",4)
- Return obj
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement