; ----------------------------------------------- ; With the assistance of...and the gratitude of...ioa747, AndrewG, and pixelsearch! ; Date: November 5th, 2024 ; ----------------------------------------------- #include #include #include #include #include #include ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $g_sSourceAudioPath = "F:\Audio\Source_Audio" Global $g_SetNameWave = "" Global $g_SetName = "" Global $g_TypeFolder = "" ; ----------------- Global $_MasterEdlFile = "" ; This global variable must always to be enabled! ; ----------------- Global $_sMasterType1Edl = "Type1.edl" Global $_sMasterType2Edl = "Type2.edl" Global $_sMasterType3Edl = "Type3.edl" Global $_sMasterType4Edl = "Type4.edl" ; ----------------------------------------------- Global $hGUI = GUICreate("WithBothVariables", 225, 165) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- ; COLUMN 3 BUTTONS Global $_sCol3Row3 = GUICtrlCreateButton("Browse Folder", 10, 10, 200, 25) Global $_sCol3Row4 = GUICtrlCreateButton("Enter Set Name", 10, 40, 200, 25) Global $_sCol3Row5 = GUICtrlCreateButton("Launch TAC", 10, 70, 200, 25) Global $_sCol3Row6 = GUICtrlCreateButton("Create Type_# Data", 10, 100, 200, 25) Global $_sCol3Row9 = GUICtrlCreateButton("Exit", 10, 130, 200, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; ----------------- ; COLUMN 3 BUTTONS Case $_sCol3Row3 _BrowseForFolder() _LaunchWavFolder($g_SetNameWave) _CreateTextListing($g_SetNameWave) _LaunchTextListing($g_SetNameWave) Case $_sCol3Row4 _EnterSetName() _DoesFolderExist($g_SetName) _CreateFolder($g_SetName) _MoveSourceAudioData($g_SetName) _LaunchWavFolder($g_SetNameWave) _CreateTextListing($g_SetNameWave) _LaunchTextListing($g_SetNameWave) Case $_sCol3Row5 _DeleteTextListing($g_SetNameWave) _LaunchTAC() Case $_sCol3Row6 _SelectWavData($g_SetName) Case $_sCol3Row9 _ExitMe() EndSwitch WEnd ; ----------------------------------------------- ; GLOBAL FUNCTIONS Func _MoveSourceAudioData($SetName) FileMove($g_sSourceAudioPath & "\*.wav", $SetName, $FC_OVERWRITE) $g_SetNameWave = $SetName EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- Func _LaunchWavFolder($SetNameWave) ;MsgBox(0, "", "The [" & $g_SetNameWave & "] global variable is being passed..." @CRLF & "...which is then being assigned to the..." & @CRLF & "...[" & $SetNameWave & "] local variable") If Not WinExists($SetNameWave) Then ShellExecute($SetNameWave) ; ----------------------------------------------- WinWaitActive($SetNameWave, "", 3) ; ----------------- WinMove($SetNameWave, "", 970, 100, 550, 650) EndFunc ;==>_LaunchWavFolder ; ----------------------------------------------- Func _CreateTextListing($SetNameWave) ;Local $MyTypeList = "" ; Assign $MyPath to $MyTypeList and create the array ;Local $MyTypeList = _FileListToArray($SetNameWave) ; ⚠ there is no file mask , cach all file ?? Local $MyTypeList = _FileListToArray($SetNameWave, "*.wav") ; ⚠ File mask...Fixed! ; ----------------------------------------------- If Not @error Then ; Create the data file _FileCreate($SetNameWave & "\FileListing.txt") ; Write the array to the data file _FileWriteFromArray($SetNameWave & "\FileListing.txt", $MyTypeList) EndIf EndFunc ;==>_CreateTextListing ; ----------------------------------------------- Func _LaunchTextListing($SetNameWave) If Not FileExists($SetNameWave & "\FileListing.txt") Then Return ; ----------------------------------------------- ShellExecute($SetNameWave & "\FileListing.txt") ; ----------------------------------------------- WinWaitActive($SetNameWave & "\FileListing.txt", "", 2) ; ----------------- WinMove($SetNameWave & "\FileListing.txt", "", 400, 100, 550, 650) EndFunc ;==>_LaunchTextListing ; ----------------------------------------------- ;COLUMN 3 BUTTONS Func _BrowseForFolder() While 1 Local $SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") ; ----------------------------------------------- If @error Then MsgBox($MB_TOPMOST, "NOTICE!", "No valid Type_#\Set_Name folder was selected." & @CRLF & "Please select a valid Type_#\Set_Name folder") ContinueLoop EndIf ; ----------------------------------------------- Local $_aType = StringSplit($SetName, "\") If $_aType[0] = 4 Then If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then $g_TypeFolder = $_aType[1] & "\" & $_aType[2] & "\" & $_aType[3] $g_SetName = $_aType[4] ; Not required!! ;DW("$g_TypeFolder=" & $g_TypeFolder & @CRLF) ;DW("$g_SetName=" & $g_SetName & @CRLF) ; Not required!! This folder structure has been created previously. ;If Not FileExists($g_TypeFolder & "\" & $g_SetName & "\edl") Then DirCreate($g_TypeFolder & "\" & $g_SetName & "\edl") ;If Not FileExists($g_TypeFolder & "\" & $g_SetName & "\wav") Then DirCreate($g_TypeFolder & "\" & $g_SetName & "\wav") _MoveSourceAudioData($g_TypeFolder & "\" & $g_SetName & "\wav") ExitLoop EndIf EndIf ; ----------------------------------------------- MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _EnterSetName() $g_SetName = InputBox("Notice!", "Enter the Type_# Set_Name...", "", " M", 200, 130) ; ----------------- If @error Then MsgBox($MB_ICONWARNING, "Notice!", "The operation was cancelled. Exiting!") Exit Else _DoesFolderExist($g_SetName) EndIf EndFunc ;==>_EnterSetName ; ----------------------------------------------- Func _DoesFolderExist($g_SetName) Local $_DoesFolderExist = FileExists($g_SetName) Local $_sTypeFolder = StringMid($g_SetName, 10, 6) Local $_sSubFolder = StringMid($g_SetName, 17) ; ----------------------------------------------- If $_DoesFolderExist Then ;MsgBox($MB_TOPMOST, "Success!", "The [" & $_sTypeFolder & "] subfolder [" & $_sSubFolder & "] already exists!") Else _CreateFolder($g_SetName) EndIf EndFunc ;==>_DoesFolderExist ; ----------------------------------------------- Func _CreateFolder($g_SetName) Local $_sCreateFolder = DirCreate($g_SetName & "\edl") Local $_sCreateFolder = DirCreate($g_SetName & "\wav") Local $_DoesFolderExist = FileExists($g_SetName) ; ----------------------------------------------- If @error Then MsgBox($MB_TOPMOST, "Failure!", "Cannot create the " & $g_SetName & " folder!") EndIf EndFunc ;==>_CreateFolder ; ----------------------------------------------- Func _DeleteTextListing($g_SetNameWave) FileDelete($g_SetNameWave & "\FileListing.txt") EndFunc ;==>_DeleteTextListing ; ----------------------------------------------- Func _LaunchTAC() Local $_sSrcPath = "D:\Install\System_Data\Apps\TAC\TAudioConverter.exe" ; ----------------------------------------------- Run($_sSrcPath) ; ----------------------------------------------- Sleep(500) WinMove("[CLASS:TAudioConverterUniqueName]", "", 160, 130, 792, 590) EndFunc ;==>_LaunchTAC ; ----------------------------------------------- Func _SelectWavData($g_SetName) Local $_ConfirmCreate = MsgBox($MB_YESNO, "Notice!", "Create " & StringMid($g_SetName, 10, 6) & " Session Data from .wav file data?") ; ----------------------------------------------- If $_ConfirmCreate = $IDYES Then Local $_WavFiles = _FileOpenDialog() Local $_DestFolder = _FileSelectFolder() Local $_sWavFolder = $_WavFiles[1] ; Contains only a path, no matter if the user has selected one or more files. ; ----------------------------------------------- For $i = 2 To $_WavFiles[0] ; First file name in element 2, and so on. Local $_WavFileName = $_sWavFolder & "\" & $_WavFiles[$i] Local $_WavBaseName = StringTrimRight($_WavFiles[$i], 4) ; ----------------- Local $_NewEdlFile = $_DestFolder & "\" & $_WavBaseName & ".edl" ; ----------------- FileCopy($_MasterEdlFile, $_NewEdlFile, $FC_NOOVERWRITE) Next ; ----------------- MsgBox($MB_ICONINFORMATION, "Success!", "The " & StringMid($g_SetName, 10, 6) & " Sesson .edl data file(s) have been successfully created!") ; ----------------------------------------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Cancelled!", "The operation was cancelled by the user.") Exit EndIf EndFunc ;==>_SelectWavData ; ----------------------------------------------- Func _FileOpenDialog() While 1 Local $_sMessage = "Please select the required source .wav file data..." Local $_ConfirmOpenDialog = MsgBox($MB_YESNO, "Notice!", $_sMessage) ; ----------------------------------------------- If $_ConfirmOpenDialog = $IDYES Then Local $_sFileOpenDialog = FileOpenDialog($_sMessage, $g_SetName & "\wav", "Wave Data (*.wav)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No source .wav file data was selected!" & @CRLF & "You must select at least one source .wav file!") ContinueLoop ; While 1 EndIf ; ----------------------------------------------- Local $_WavFiles = StringSplit($_sFileOpenDialog, "|") ; ----------------------------------------------- If $_WavFiles[0] = 1 Then ; If only one file was selected by the user. Local $iPos_LastBackslash = StringInStr($_WavFiles[1], "\", 0, -1) ; -1 starts from the right (+++). ; ----------------------------------------------- ReDim $_WavFiles[3] $_WavFiles[2] = StringMid($_WavFiles[1], $iPos_LastBackslash + 1) ; The file name. $_WavFiles[1] = StringLeft($_WavFiles[1], $iPos_LastBackslash - 1) ; The path without last backslash. $_WavFiles[0] = 2 EndIf ; ----------------- Return $_WavFiles ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileOpenDialog ; ----------------------------------------------- Func _FileSelectFolder() While 1 Local $_Message = "Please select the Destination folder for the Session .edl file(s)..." Local $_ConfirmFileSelect = MsgBox($MB_YESNO, "Notice!", $_Message) ; ----------------------------------------------- If $_ConfirmFileSelect = $IDYES Then Local $_DestFolder = FileSelectFolder($_Message, $g_SetName) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No destination Session .edl folder was selected!" & @CRLF & "You must select a destination Session .edl folder!") ContinueLoop ; While 1 ; ----------------------------------------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_1" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType1Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_2" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType2Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_3" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType3Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_4" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType4Edl ; ----------------- Else MsgBox($MB_ICONERROR, "Notice!", "The " & $_MasterEdlFile & " Session .edl file was not found.") ContinueLoop ; While 1 EndIf ; ----------------- Return $_DestFolder ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileSelectFolder ; ----------------------------------------------- Func _ExitMe() Exit EndFunc ;==>_ExitMe ; -----------------------------------------------