mr-es335 Posted 6 hours ago Share Posted 6 hours ago Good day, I hope that the day finds you well! It would be greatly appreciated if someone would check the following script: Preamble There are four different types of audio data: Type_1, Type_2, and so on There is a source location consisting of audio data files [F:Audio\SetName\wav] There is a destination location consisting of "session" data files [F:Audio\SetName\edl] The concept here is threefold: 1) Read the contents of a the \wav folder 2) Place that content into an array 3) Make copies of a master data file [\Show\Session_Data\Type_#], this master data file being copied-and-renamed based on the data stored in the array Following is the "completed" script: expandcollapse popup; ----------------------------------------------- #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $sourceFolder = "" Global $destFolder = "" ; ----------------------------------------------- _SelectWavFolder() ; ----------------------------------------------- Func _SelectWavFolder() Local $confirmCreate = MsgBox(4, "Continue?", "Copy-and-rename Type_# file data from .wav file data?") ; ----------------------------------------------- If $confirmCreate = 6 Then Local $sourceMessage = "Select the source .wav data folder..." Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\") ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error!", "No .wav file source folder selected...exiting.") Return EndIf ; ----------------------------------------------- Local $destMessage = "Select the destination folder for the copied-and-renamed .edl data..." $destFolder = FileSelectFolder($destMessage, "F:\Audio\") ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error!", "No destination .edl file folder selected...exiting.") Return Else _CreateArray($sourceFolder) EndIf 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($wavFiles, $masterEdlFile) EndIf EndFunc ;==>_DeriveType ; ----------------------------------------------- Func _RenameEdls($wavFiles, $masterEdlFile) 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 .edl files have not been created successfully.") Return Else MsgBox($MB_TOPMOST, "Success!", "All .edl files have been created successfully.") EndIf EndFunc ;==>_RenameEdls ; ----------------------------------------------- It would be greatly appreciated if I would be instructed as to what is incorrect with this script, with the sole objective that I may learn and attempt how to "fix" those anomalies! Any assistance in this matter would be greatly appreciated! Thank you! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now