mr-es335 Posted November 22, 2024 Posted November 22, 2024 (edited) 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: [Updated: 2:35 PM 11/22/2024] expandcollapse popup; ----------------------------------------------- ; With the assistance of...and the gratitude of...ioa747! ; Date: October 19th, 2024 ; ----------------------------------------------- #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $sourceFolder = "" Global $destFolder = "" ; ----------------------------------------------- _SelectWavFolder() ; ----------------------------------------------- Func _SelectWavFolder() 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..." ; ----------------------------------------------- ; 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 ; ----------------------------------------------- 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! Edited November 22, 2024 by mr-es335 Updated script mr-es335 Sentinel Music Studios
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