mr-es335 Posted November 23, 2024 Posted November 23, 2024 (edited) Good day, I hope that the day finds you well! The following script "works" for the most part... expandcollapse popup; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $g_SetName = "" ; ----------------------------------------------- _BrowseForFolder() ; Requires the following function: ; _MoveSourceAudioData() ; ----------------------------------------------- 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 Else MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") ContinueLoop EndSelect WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- However, if I happen to select a folder path that is incorrect - that is, where that path does not meet certain criteria, the scripts fails. • See attached image The path must consist of three elements, 1) F:\Audio\, 2) a $TypeName variable, and 3) a $SetName variable, along with the supporting "\'s". • Anything more-or-less must be rejected. • As can be observed in the image, I selected a subfolder of "F:\Audio\$TypeName\$SetName" Any-and-all of my attempts at resolving the above has not been successful! Any comments and|or suggestion would be greatly appreciated. Thank you for your time...appreciated! PS: I have attached the supporting script _MoveSourceAudioData.au3 Edited November 23, 2024 by mr-es335 mr-es335 Sentinel Music Studios
Dan_555 Posted November 23, 2024 Posted November 23, 2024 When something is not working, the usual way to debug it to write everything into the console and double check the output. Replace the FileMove with consolWrite command then look: Is the parameter right ? does the case works ? do the variables contain the correct path ? Do the paths exist ? Some of my script sourcecode
mr-es335 Posted November 23, 2024 Author Posted November 23, 2024 Dan_555, Thanks! Can the error checking not be done within the _BrowseForFolder function? mr-es335 Sentinel Music Studios
mr-es335 Posted November 23, 2024 Author Posted November 23, 2024 Attempt #1 ; ------------------------------------------------------ #include <MsgBoxConstants.au3> ; ------------------------------------------------------ _CheckPath() ; ------------------------------------------------------ Func _CheckPath() ; F:\Audio\Type_1\Test\wav Local $WrongName = "F:\Audio\Type_1\Test\wav" Local $One = StringMid($WrongName, 1, 9) ;MsgBox(0, "", $One) Local $Two = StringMid($WrongName, 10, 7) ;MsgBox(0, "", $Two) Local $Three = StringMid($WrongName, 17, 4) ;MsgBox(0, "", $Three) Local $Four = StringMid($WrongName, 21, 4) ;MsgBox(0, "", $Four) Local $CorrectPath = $One & $Two & $Three Local $IncorrectPath = $One & $Two & $Three & $Four ;MsgBox(0, "", "Correct path is: " & $CorrectPath) ;MsgBox(0, "", "Incorrect path is: " & $IncorrectPath) Local $Result = StringCompare($CorrectPath, $IncorrectPath) If $Result = 0 Then MsgBox(0, "", "Great!!") Else MsgBox(0, "", "Not Great!!") Endif EndFunc ;==>_CheckPath ; ------------------------------------------------------ mr-es335 Sentinel Music Studios
Dan_555 Posted November 23, 2024 Posted November 23, 2024 (edited) in the _BrowseFolder() function you are calling the file dialog Local $_aGetType = StringSplit($g_SetName, "\") ; ----------------------------------------------- for $x=1 to $_aGetType[0] ConsoleWrite ($_aGetType[$x] & @CRLF) Next This would display the selected path into the console window. I guess you should use IF statements instead of the select ... Edited November 23, 2024 by Dan_555 Some of my script sourcecode
Dan_555 Posted November 23, 2024 Posted November 23, 2024 And as for the last script, i would display it like this: #include <MsgBoxConstants.au3> ; ------------------------------------------------------ _CheckPath() ; ------------------------------------------------------ Func _CheckPath() ; F:\Audio\Type_1\Test\wav Local $WrongName = "F:\Audio\Type_1\Test\wav" Local $One = StringMid($WrongName, 1, 9) ;MsgBox(0, "", $One) Local $Two = StringMid($WrongName, 10, 7) ;MsgBox(0, "", $Two) Local $Three = StringMid($WrongName, 17, 4) ;MsgBox(0, "", $Three) Local $Four = StringMid($WrongName, 21, 4) ;MsgBox(0, "", $Four) Local $CorrectPath = $One & $Two & $Three Local $IncorrectPath = $One & $Two & $Three & $Four ;MsgBox(0, "", "Correct path is: " & $CorrectPath) ;MsgBox(0, "", "Incorrect path is: " & $IncorrectPath) Local $Result = StringCompare($CorrectPath, $IncorrectPath) If $Result = 0 Then MsgBox(0, "", "Great!!") Else MsgBox(0, "", "Not Great!!") ConsoleWrite ($CorrectPath & @CRLF & $IncorrectPath & @CRLF) Endif EndFunc ;==>_CheckPath ; ------------------------------------------------------ so you can see it in the console window what is checked vs what you have Some of my script sourcecode
pixelsearch Posted November 23, 2024 Posted November 23, 2024 @mr-es335 What about changing this single line in your initial script ? ; Case $_aGetType[0] < 3 Case $_aGetType[0] <> 3 mr-es335 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
ioa747 Posted November 23, 2024 Posted November 23, 2024 the msg Windows cannot find 'F: Audio \Type_1\Test\wav\wav’. Make sure you typed the name correctly, and then try again. it has to do with the other script why did you separate them and give them to us separately, and we have to join them ourselves? I know that I know nothing
mr-es335 Posted November 23, 2024 Author Posted November 23, 2024 (edited) Hello, I provided the other script only for completeness. If I understand things correctly, all of the necessary error checking should be able to be managed within the _BrowseForFolder function. Would this not be a correct assertion? The _MoveSourceAudioData function is really not required to make the _BrowseForFolder function..."functional". ioa747, you stated, "the msg, Windows cannot find 'F: Audio \Type_1\Test\wav\wav’. Make sure you typed the name correctly, and then try again." I am browsing for the folder path...not typing in the path. • For whatever reason, I forgot that I am only to select the SetName folder...NOT the \edl or \wav folder...the latter is what I was doing to generate the error message. • I want to create an error-checking routine that ensure that the only the proper path is selected. I do hope that this all makes sense? Edited November 23, 2024 by mr-es335 mr-es335 Sentinel Music Studios
Solution ioa747 Posted November 24, 2024 Solution Posted November 24, 2024 (edited) I tried it and I couldn't produce the message above no matter what I chose. and that's why I mentioned it I also shrunk the function a bit. Func _BrowseForFolder() While 1 $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") ; "F:\Audio\" ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) ; ----------------------------------------------- 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 ; ----------------------------------------------- If StringRegExp($g_SetName & "\", "\\Type_[1-4]\\") Then ConsoleWrite("$_aGetType=" & $g_SetName & @CRLF) ;_MoveSourceAudioData($g_SetName) ExitLoop Else MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") EndIf WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Edited November 24, 2024 by ioa747 correction [1-4] mr-es335 1 I know that I know nothing
mr-es335 Posted November 24, 2024 Author Posted November 24, 2024 ioa747, I stripped the attached script down to what I "believed" to be the basics! • See attached..._Working.au3 • The attached script is a stripped-down version of my complete "menu-system". To produce the error, perform the following: Launch: _Working 1) Select: Browse Folder 2) Navigate to: F:\Audio\Type_1\Initial\wav 3) Select: Select Folder • Error is produced _Working.au3 mr-es335 Sentinel Music Studios
ioa747 Posted November 24, 2024 Posted November 24, 2024 (edited) 1 hour ago, mr-es335 said: 2) Navigate to: F:\Audio\Type_1\Initial\wav the problem is in the _MoveSourceAudioData function because the path $g_SetName already contains the wav folder, and you are adding it again extra Case StringMid($g_SetName, 10, 6) = "Type_1" FileMove($g_sSourceAudioPath & "\*.*", $g_SetName & "\wav", $FC_OVERWRITE) $g_SetNameWave = $g_SetName & "\wav" ConsoleWrite("$g_SetNameWave=" & $g_SetNameWave & @CRLF) ExitLoop Edited November 24, 2024 by ioa747 I know that I know nothing
ioa747 Posted November 24, 2024 Posted November 24, 2024 (edited) As you can see, I couldn't find this because the _MoveSourceAudioData function isn't in this script, it's not even in the other one. But I have an imagination. Edited November 24, 2024 by ioa747 I know that I know nothing
ioa747 Posted November 24, 2024 Posted November 24, 2024 (edited) something else I noticed in this function is that in all cases the code is the same ; ----------------------------------------------- ; 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 ; ----------------------------------------------- which means it could be written like this ; ----------------------------------------------- ; GLOBAL FUNCTIONS Func _MoveSourceAudioData($g_SetName) FileMove($g_sSourceAudioPath & "\*.*", $g_SetName, $FC_OVERWRITE) $g_SetNameWave = $g_SetName EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- I don't know if I'm missing something. Edited November 24, 2024 by ioa747 I know that I know nothing
Dan_555 Posted November 24, 2024 Posted November 24, 2024 (edited) Question: your F drive is what ? I changed your script to reflect my R: drive which is a ram drive when i selected the R:/Audio/Type_1 it had no wav folder in it, and the error in your picture appeared. But, i noticed that a wav folder was created after the message box was closed, so i ran it again, selected the same folder and the error didn't popped up ... I guess your F drive must be write protected or something ... Edited November 24, 2024 by Dan_555 Some of my script sourcecode
mr-es335 Posted November 24, 2024 Author Posted November 24, 2024 (edited) Dan_555, Sorry..."No!" The entire script, which consists of the functions listed in the "_Working" example, Everything works as it should, EXCEPT, when I select a folder that is "deeper" than what is required. For example: 1) F:\Audio: Generates the error: "No valid Type_#\Set_Name folder was selected." & @CRLF & "Please select a valid Type_#\Set_Name folder") - which is what I want! 2) F:\Audio\Type_1: Generates the error as shown in Error_1 3) F:\Audio\Type_1\Initial: Generates no errors and continues with the next three functions in "Case $_sCol3Row3" 4) F:\Audio\Type_1\Initial\wav: Generates the error as shown in Error_2 Thus, the ONLY CORRECT PATH should be F:\Audio\Type_1\Initial [...or what I refer to as "Root\TypeName\SetName\" - which I am attempting to resolve at the present moment. According to ioa747, the issue is with the _MoveSourceAudioData function, and not with the _BrowseForFolder function - where I believe the error checking should have occurred. It looks to be as if I was incorrect in my assertions here? I do hope that this all makes sense? Edited November 24, 2024 by mr-es335 mr-es335 Sentinel Music Studios
mr-es335 Posted November 24, 2024 Author Posted November 24, 2024 Hello, Here is updated "complete" script: _Working2.au3 mr-es335 Sentinel Music Studios
Dan_555 Posted November 24, 2024 Posted November 24, 2024 Does that mean you solved the problem ? Some of my script sourcecode
mr-es335 Posted November 24, 2024 Author Posted November 24, 2024 Dan_555, No! It was just that ioa747 noted that the initial _Working.au3 script apparently did not contain the _MoveSourceAudioData function - which it however, did. I simply updated the GUI... ioa747 1 mr-es335 Sentinel Music Studios
ioa747 Posted November 24, 2024 Posted November 24, 2024 (edited) Is this part ok? expandcollapse popup; ----------------------------------------------- #include <File.au3> #include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $g_sSourceAudioPath = "F:\Audio\Source_Audio" Global $g_SetNameWave = "" Global $g_SetName = "" Global $g_TypeFolder = "" ;~ Global $sourceFolder = "" ; ⚠ not using Global $g_DestFolder = "" ; ⚠ i put $g_ in front ; ----------------------------------------------- Global $hGUI = GUICreate("Session|Show Development Main Menu", 830, 285) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- ; COLUMN 3 BUTTONS Global $_sCol3Row3 = GUICtrlCreateButton("Browse Folder", 420, 70, 200, 25) Global $_sCol3Row4 = GUICtrlCreateButton("Enter Set Name", 420, 100, 200, 25) Global $_sCol3Row5 = GUICtrlCreateButton("Launch TAC", 420, 130, 200, 25) Global $_sCol3Row6 = GUICtrlCreateButton("Create Type_# Data", 420, 160, 200, 25) Global $_sCol3Row9 = GUICtrlCreateButton("Exit", 420, 250, 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 $_sCol3Row9 _ExitMe() EndSwitch WEnd ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") ; "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] ; F:\Audio\$_aType[3]\$_aType[4] $g_SetName = $_aType[4] DW("$g_TypeFolder=" & $g_TypeFolder & @CRLF) DW("$g_SetName=" & $g_SetName & @CRLF) 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 _MoveSourceAudioData($SetName) Local $Dest = (StringRight($SetName, 1) = "\" ? $SetName : $SetName & "\") FileMove($g_sSourceAudioPath & "\*.*", $Dest, $FC_OVERWRITE) $g_SetNameWave = $SetName DW("$g_SetNameWave=" & $g_SetNameWave & @CRLF) EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- Func _LaunchWavFolder($SetNameWave) If Not WinExists($SetNameWave) Then ShellExecute($SetNameWave) WinWaitActive($SetNameWave, "", 3) WinMove($SetNameWave, "", 970, 100, 550, 650) ; ⚠ my title in win10 = wav EndFunc ;==>_LaunchWavFolder ; ----------------------------------------------- Func _CreateTextListing($SetNameWave) Local $MyT1List = '' ; Assign $MyPath to $MyT1List and create the array $MyT1List = _FileListToArray($SetNameWave) ; ⚠ there is no file mask , cach all file ?? If Not @error Then ; ⚠ avoid empty FileListing.txt ; Create the data file _FileCreate($SetNameWave & "\FileListing.txt") ; Write the array to the data file _FileWriteFromArray($SetNameWave & "\FileListing.txt", $MyT1List) EndIf EndFunc ;==>_CreateTextListing ; ----------------------------------------------- Func _LaunchTextListing($SetNameWave) If Not FileExists($SetNameWave & "\FileListing.txt") Then Return ; ⚠ Avoid error if not exist ShellExecute($SetNameWave & "\FileListing.txt") WinWaitActive($SetNameWave & "\FileListing.txt", "", 3) WinMove($SetNameWave & "\FileListing.txt", "", 400, 100, 550, 650) ; ⚠ my title in win10 = FileListing.txt - Notepad EndFunc ;==>_LaunchTextListing ; ----------------------------------------------- Func _ExitMe() Exit EndFunc ;==>_ExitMe ; ----------------------------------------------- Func DW($sString, $iLine = @ScriptLineNumber) ConsoleWrite("(" & $iLine & ") " & $sString) EndFunc ;==>DW ; ----------------------------------------------- Edited November 24, 2024 by ioa747 UpDate I know that I know nothing
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