; ----------------------------------------------- #include #include #include #include #include ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $g_sSourceAudioPath = "F:\Audio\Source_Audio" Local $g_SetNameWave = "" Local $g_SetName = "" Local $sourceFolder = "" Local $destFolder = "" ; ----------------------------------------------- Global $hGUI = GUICreate("Session|Show Development Main Menu", 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 _SelectWavFolder($g_SetName) Case $_sCol3Row9 _ExitMe() EndSwitch WEnd ; ----------------------------------------------- ; GLOBAL FUNCTIONS Func _MoveSourceAudioData($g_SetName) While 1 Select Case StringMid($g_SetName, 10, 6) = "Type_1" FileMove($g_sSourceAudioPath & "\*.*", $g_SetName & "\wav", $FC_OVERWRITE) $g_SetNameWave = $g_SetName & "\wav" ExitLoop Case StringMid($g_SetName, 10, 6) = "Type_2" FileMove($g_sSourceAudioPath & "\*.*", $g_SetName & "\wav", $FC_OVERWRITE) $g_SetNameWave = $g_SetName & "\wav" ExitLoop Case StringMid($g_SetName, 10, 6) = "Type_3" FileMove($g_sSourceAudioPath & "\*.*", $g_SetName & "\wav", $FC_OVERWRITE) $g_SetNameWave = $g_SetName & "\wav" ExitLoop Case StringMid($g_SetName, 10, 6) = "Type_4" FileMove($g_sSourceAudioPath & "\*.*", $g_SetName & "\wav", $FC_OVERWRITE) $g_SetNameWave = $g_SetName & "\wav" ExitLoop EndSelect WEnd EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- Func _LaunchWavFolder($g_SetNameWave) ShellExecute($g_SetNameWave) ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave, "", 970, 100, 550, 650) EndFunc ;==>_LaunchWavFolder ; ----------------------------------------------- Func _CreateTextListing($g_SetNameWave) Local $MyT1List = '' ; ----------------------------------------------- ; Assign $MyPath to $MyT1List and create the array $MyT1List = _FileListToArray($g_SetNameWave) ; Create the data file _FileCreate($g_SetNameWave & "\FileListing.txt") ; Write the array to the data file _FileWriteFromArray($g_SetNameWave & "\FileListing.txt", $MyT1List) EndFunc ;==>_CreateTextListing ; ----------------------------------------------- Func _LaunchTextListing($g_SetNameWave) ShellExecute($g_SetNameWave & "\FileListing.txt") ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave & "\FileListing.txt", "", 400, 100, 550, 650) ; ----------------------------------------------- EndFunc ;==>_LaunchTextListing ; ----------------------------------------------- ;COLUMN 3 BUTTONS Func _BrowseForFolder() While 1 $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") ; ----------------------------------------------- If @error Then MsgBox($MB_TOPMOST, "", "No valid Type_#\Set_Name folder was selected." & @CRLF & "Please select a valid Type_#\Set_Name folder") ContinueLoop EndIf ; ----------------------------------------------- Local $_aGetType = StringSplit($g_SetName, "\") ; ----------------------------------------------- Select Case $_aGetType[0] < 3 MsgBox($MB_TOPMOST, "NOTICE!", "You must select a valid Type_#\Set_Name folder...") ContinueLoop Case $_aGetType[3] = "Type_1" _MoveSourceAudioData($g_SetName) ExitLoop Case $_aGetType[3] = "Type_2" _MoveSourceAudioData($g_SetName) ExitLoop Case $_aGetType[3] = "Type_3" _MoveSourceAudioData($g_SetName) ExitLoop Case $_aGetType[3] = "Type_4" _MoveSourceAudioData($g_SetName) ExitLoop Case Else MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") ContinueLoop EndSelect 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 _SelectWavFolder($g_SetName) Local $sourceMessage = "Select the source .wav data folder..." Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\") ; ----------------------------------------------- If @error Then MsgBox($MB_TOPMOST, "Error!", "No .wav file source folder selected...exiting.") Return EndIf ; ----------------------------------------------- Local $destMessage = "Select the destination folder for the copied-and-renamed .edl data..." ; ----------------------------------------------- ; Obtain $sourceFolder path including the [SetName], ; Store the result in the variable: $sourceFolderpath Local $sourceFolderpath = $sourceFolder ; Via StringSplit, the wav portion will be stripped from the path Local $_sGetSetNamePath = StringSplit($sourceFolderpath, "wav", $STR_ENTIRESPLIT)[1] ; ----------------- $destFolder = FileSelectFolder($destMessage, $_sGetSetNamePath) ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error!", "No destination .edl file folder selected...exiting.") Return Else _CreateArray($sourceFolder) EndIf EndFunc ;==>_SelectWavFolder ; ----------------------------------------------- Func _CreateArray($sourceFolder) Local $wavFiles = _FileListToArray($sourceFolder, "*.wav", $FLTA_FILES) ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error", "No .wav files found in the selected folder.") Return Else _DeriveType($sourceFolder, $wavFiles) EndIf EndFunc ;==>_CreateArray ; ----------------------------------------------- Func _DeriveType($sourceFolder, $wavFiles) ; Derive "Type#" from the following "F:\Audio\Type_#" Local $Left = StringMid($sourceFolder, 10, 4) Local $Right = StringMid($sourceFolder, 15, 1) Local $_sGetTypeName = $Left & $Right ; ----------------------------------------------- Local $masterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sGetTypeName & ".edl" ; ----------------------------------------------- If Not FileExists($masterEdlFile) Then MsgBox($MB_ICONERROR, "Error", "The " & $_sGetTypeName & ".edl file was not found.") Return Else _RenameEdls($_sGetTypeName, $wavFiles, $masterEdlFile) EndIf EndFunc ;==>_DeriveType ; ----------------------------------------------- Func _RenameEdls($_sGetTypeName, $wavFiles, $masterEdlFile) MsgBox($MB_TOPMOST, "An Important Note!", "Any existing " & $_sGetTypeName & ".edl data WILL NOT be overwritten!") ; ----------------------------------------------- For $i = 1 To $wavFiles[0] Local $wavFileName = $wavFiles[$i] Local $wavBaseName = StringTrimRight($wavFileName, 4) ; ----------------- Local $newEdlFile = $destFolder & "\" & $wavBaseName & ".edl" ; ----------------- FileCopy($masterEdlFile, $newEdlFile, $FC_NOOVERWRITE) Next ; ----------------- If Not FileExists($masterEdlFile) Then MsgBox($MB_TOPMOST, "Error!", "All Master " & $_sGetTypeName & ".edl files have not been successfully copied-and-renamed!") Return Else MsgBox($MB_TOPMOST, "Success!", "All Master " & $_sGetTypeName & ".edl files have been successfully copied-and-renamed.") EndIf EndFunc ;==>_RenameEdls ; ----------------------------------------------- Func _ExitMe() Exit EndFunc ;==>_ExitMe ; -----------------------------------------------