ioa747 Posted December 12 Posted December 12 In both cases we have two arrays one from FileReadToArray (from list.txt) based on 0 and one from _FileListToArray (from audio files) based on 1 (0 has the count) and we create a loop so that index 1 from table _FileListToArray is renamed with the name from index 0 of table filereadtoarray index 2 from table _FileListToArray is renamed with the name from index 1 of table filereadtoarray index 3 from table _FileListToArray is renamed with the name from index 2 of table filereadtoarray ... ... I know that I know nothing
mr-es335 Posted December 13 Author Posted December 13 Good day, Well, it would appear that my MAJOR ISSUE was WAS NOT including the folders that the data was located in!!! Sure, I was testing the filenames...but NOT the paths where those filenames were located!!! "Duh!!!" and "Duh!, Duh!" So, without... #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sTextFolder = "I:\Live_Rig\Scripts\Development\_FileMove\HelpFile\Data\FileListing.txt" ; Read the text file Local $sTextFileToRead = FileReadToArray($sTextFolder) For $i = 0 To UBound($sTextFileToRead) - 1 ConsoleWrite($sTextFileToRead[$i] & @CRLF) Next Local $sDataFolder = "I:\Live_Rig\Scripts\Development\_FileMove\HelpFile\Data\" ; Read the folder contents Local $aFileList = _FileListToArray($sDataFolder, "*.wma") For $i = 1 To $aFileList[0] ConsoleWrite($aFileList[$i] & @CRLF) Next EndFunc ;==>Example ...and, with... #include <Array.au3> #include <File.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sTextFolder = "I:\Live_Rig\Scripts\Development\_FileMove\HelpFile\Data\FileListing.txt" ; Read the text file Local $sTextFileToRead = FileReadToArray($sTextFolder) For $i = 0 To UBound($sTextFileToRead) - 1 ConsoleWrite($sTextFileToRead[$i] & @CRLF) Next Local $sDataFolder = "I:\Live_Rig\Scripts\Development\_FileMove\HelpFile\Data\" ; Read the folder contents Local $aFileList = _FileListToArray($sDataFolder, "*.wma") For $i = 1 To $aFileList[0] ConsoleWrite($sDataFolder & $aFileList[$i] & @CRLF) Next EndFunc ;==>Example Thus, I do still have more testing to do...and will keep ya'all updated as to my progress [...or it is REGRESS?!?] “No. No. I’m listening. It just takes me a minute to process that much stupid all at once.” Sheldon (Big Bang Theory) mr-es335 Sentinel Music Studios
mr-es335 Posted December 13 Author Posted December 13 Good day, Again, my many thanks to ioa747...whom has managed to "save my bacon" on numerous occasions! As noted, here is my "code": ; Update the folder data For $i = 1 To $sNewName[0+1] ConsoleWrite($sNewName[$i] & @CRLF) ConsoleWrite($sOldName[$i] & @CRLF) FileMove($sOldName[$i], $sNewName[$i], $FC_OVERWRITE) Next ...and here is ioa747's offering: ; Update the folder data For $i = 0 to UBound($sNewName) - 1 FileMove($sOldName[$i], $sNewName[$i], $FC_OVERWRITE) ConsoleWrite("FileMove:" & $sDataFolder & $sOldName[$i + 1] & ", " & $sDataFolder & $sNewName[$i] & ".wma" & @CRLF) Next So: ; FileMove($sOldName[$i], $sNewName[$i], $FC_OVERWRITE) ; VERSUS ; FileMove($sDataFolder & $sOldName[$i + 1], $sDataFolder & $sNewName[$i] & ".wma", $FC_OVERWRITE) ...an OBVIOUS difference!! Thanks again...ioa747! Much appreciated! ioa747 1 mr-es335 Sentinel Music Studios
ioa747 Posted December 13 Posted December 13 (edited) don't forget the For $i = 1 To $sNewName[0+1] because $sNewName[0+1] = Celeste Edited December 13 by ioa747 I know that I know nothing
mr-es335 Posted December 13 Author Posted December 13 ioa747, Am I to replace "For $i = 0 To UBound($sNewName) - 1" with "For $i = 1 To $sNewName[0 + 1]"? Please advise. mr-es335 Sentinel Music Studios
ioa747 Posted December 13 Posted December 13 oh no just in ...an OBVIOUS difference!! I know that I know nothing
mr-es335 Posted December 13 Author Posted December 13 ioa747, Okay! Is the "UBOUND" required in: "For $i = 0 To UBound($sNewName) - 1" If so, what is the UBOUND for? • I have yet to find a truly understandable explanation of r the employment of UBOUND! mr-es335 Sentinel Music Studios
ioa747 Posted December 13 Posted December 13 https://www.autoitscript.com/autoit3/docs/functions/UBound.htm I know that I know nothing
mr-es335 Posted December 13 Author Posted December 13 (edited) ioa747, My brain...whatever is left of it, is a bit OVERWHELMED at the moment. I really would prefer NOT having to learn anything else NEW! What is wrong\not wrong with this? ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aArray1 = FileReadToArray($file_to_read) ; ----------------------------------------------- $file_to_write = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $iLineCount = @extended Local $aArray2 = _FileListToArray($file_to_write, "*.*", $FLTA_FILES) ; ----------------------------------------------- For $i = 0 To $iLineCount - 1 FileMove($file_to_write & $aArray2[$i + 1], $file_to_write & $aArray1[$i] & ".wma", $FC_OVERWRITE) Next EndFunc ;==>_Example ; ----------------------------------------------- Have a peep... _UpdateSrcAudio_a.au3 _UpdateSrcAudio_b.au3 Edited December 13 by mr-es335 mr-es335 Sentinel Music Studios
ioa747 Posted December 13 Posted December 13 (edited) a good tool when working with arrays is _ArrayDisplay($aArray1) to visualize things, believe me , it helps ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aArray1 = FileReadToArray($file_to_read) Local $iLineCount = @extended ;~ _ArrayDisplay($aArray1) ; ----------------------------------------------- $file_to_write = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aArray2 = _FileListToArray($file_to_write, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aArray2) ; ----------------------------------------------- For $i = 0 To $iLineCount - 1 ;~ FileMove($file_to_write & $aArray2[$i + 1], $file_to_write & $aArray1[$i] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $file_to_write & $aArray2[$i + 1] & ", " & $file_to_write & $aArray1[$i] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; ----------------------------------------------- as well as the correct nomenclature ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aList = FileReadToArray($file_to_read) Local $iLineCount = @extended ;~ _ArrayDisplay($aList) ; ----------------------------------------------- $Audio_folder = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aFile = _FileListToArray($Audio_folder, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aFile) ; ----------------------------------------------- For $i = 0 To $iLineCount - 1 ;~ FileMove($Audio_folder & $aFile[$i + 1], $Audio_folder & $aList[$i] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $Audio_folder & $aFile[$i + 1] & ", " & $Audio_folder & $aList[$i] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; ----------------------------------------------- Edited December 13 by ioa747 Musashi 1 I know that I know nothing
mr-es335 Posted December 14 Author Posted December 14 Hello, The method for accessing array data - is one more preferable over another? For example, in the two script examples noted above, is "For $i = 1 To $sNewName[0+1]" preferable over "For $i = 0 to UBound($sNewName) - 1"? Any clarification in this matter would be greatly appreciated! mr-es335 Sentinel Music Studios
ioa747 Posted December 14 Posted December 14 (edited) You will tell me. ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aList = FileReadToArray($file_to_read) ;~ Local $iLineCount = @extended ;~ _ArrayDisplay($aList) ; ----------------------------------------------- $Audio_folder = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aFile = _FileListToArray($Audio_folder, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aFile) ; ----------------------------------------------- For $i = 1 To $aFile[0] ;~ FileMove($Audio_folder & $aFile[$i], $Audio_folder & $aList[$i - 1] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $Audio_folder & $aFile[$i] & ", " & $Audio_folder & $aList[$i - 1] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; ----------------------------------------------- Edited December 14 by ioa747 mr-es335 1 I know that I know nothing
ioa747 Posted December 14 Posted December 14 the For $i = 1 To $sNewName[0+1] is wrong, it does not work. Because as I mentioned above, $sNewName[0+1] = Celeste, i.e. For $i = 1 To Celeste ?? mr-es335 1 I know that I know nothing
mr-es335 Posted December 14 Author Posted December 14 ioa747, As you noted: "You will tell me." I see no difference between the two script examples namely, "For $i = 0 To $sNewName[0+1]" preferable over "For $i = 0 to UBound($sNewName) - 1"? Thanks for the clarification! Appreciated! mr-es335 Sentinel Music Studios
ioa747 Posted December 14 Posted December 14 (edited) here is an alternative #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- _Example() ; ----------------------------------------------- Func _Example() Local $file_to_read = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\FileListing.txt" Local $aList _FileReadToArray($file_to_read, $aList) ;~ _ArrayDisplay($aList) ; ----------------------------------------------- Local $Audio_folder = "I:\Live_Rig\Scripts\Development\_RenameAudioData\ioa747\Audio\" Local $aFile = _FileListToArray($Audio_folder, "*.*", $FLTA_FILES) ;~ _ArrayDisplay($aFile) ; ----------------------------------------------- For $i = 1 To $aFile[0] ;~ FileMove($Audio_folder & $aFile[$i], $Audio_folder & $aList[$i] & ".wma", $FC_OVERWRITE) ConsoleWrite("FileMove:" & $Audio_folder & $aFile[$i] & ", " & $Audio_folder & $aList[$i] & ".wma" & @CRLF) Next EndFunc ;==>_Example ; ----------------------------------------------- Edited December 14 by ioa747 I know that I know nothing
Musashi Posted December 14 Posted December 14 6 hours ago, mr-es335 said: Any clarification in this matter would be greatly appreciated! You are probably confused by the difference between 0-based and 1-based arrays. @TheDcoder has created a helpful tutorial on arrays. This contains, for instance, an explanation of this particular topic. Excerpt : UBound returns the no. of elements in an array with the index starting from 1! That's right, you need to remove 1 from the total no. of elements in order to process the array because the index of an array starts with 0! So append a simple - 1 to the statment: TheDcoder and mr-es335 1 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
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