mr-es335 Posted December 8, 2023 Share Posted December 8, 2023 Good day, I have been attempting to convert a cmd script to Autoit...and much of that script - I do believe, has been updated accordingly. However, there is one particular section that I have been having issues with - and after much "head-banging" I find that I do require outside assistance. I have taken a scree capture of both sections...highlighting those sections that are of particular concern : The Objective The objective here is to copy .ini data from the same "named" folders located in "D:\Install\System_Config\ini_files\E\" and copy that data to data "$folders1 = "(Desktop Text Downloads Images Video)" respectively. 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...
mr-es335 Posted December 8, 2023 Author Share Posted December 8, 2023 Good day, I do believe the following would be correct WITHOUT the for loop? ;------------------------------------------------ Local $oldPath = "D:\Install\System_Config\ini_files\E\" Local $newPath = "E:\" ;------------------ FileCopy($oldPath & "\Desktop\desktop.ini", $newPath & "\Desktop", $FC_OVERWRITE) FileCopy($oldPath & "\Text\desktop.ini", $newPath & "\Text", $FC_OVERWRITE) FileCopy($oldPath & "\Downloads\desktop.ini", $newPath & "\Downloads", $FC_OVERWRITE) FileCopy($oldPath & "\Images\desktop.ini", $newPath & "\Images", $FC_OVERWRITE) FileCopy($oldPath & "\Video\desktop.ini", $newPath & "\Video", $FC_OVERWRITE) SplashTextOn("Notice!", "Copy [E] .ini files completed...", 350, 50, -1, -1) Sleep(3000) ;------------------------------------------------ PS: I do believe that IF I am able to understand what the cmd script is doing, I will then be in a better position to make the transition to AutoIt? mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Solution ioa747 Posted December 8, 2023 Solution Share Posted December 8, 2023 (edited) see if you need an adjustment ; https://www.autoitscript.com/forum/topic/211214-cmd-to-autoit/#comment-1527768 #include <File.au3> _FindAllFile() ;---------------------------------------------------------------------------------------- Func _FindAllFile() Local $oldPath = "D:\Install\System_Config\ini_files\E\" Local $newPath = "E:\" Local $Folder $ArraySrtfiles = _FileListToArrayRec($oldPath, "desktop.ini", $FLTAR_FILES, $FLTAR_RECUR) If Not IsArray($ArraySrtfiles) Then ConsoleWrite($oldPath & " = Invalid input path" & @CRLF) Return Else For $x = 1 To $ArraySrtfiles[0] ConsoleWrite($oldPath & $ArraySrtfiles[$x] & " -> " & $newPath & $ArraySrtfiles[$x] & @CRLF) FileCopy($oldPath & $ArraySrtfiles[$x], $newPath & $ArraySrtfiles[$x], 1) $Folder = StringLeft($newPath & $ArraySrtfiles[$x], StringInStr($newPath & $ArraySrtfiles[$x], '\', 0, -1)) FileSetAttrib($Folder, "+R") Next EndIf EndFunc ;==>_FindAllFile ;---------------------------------------------------------------------------------------- Edited December 8, 2023 by ioa747 Added FileSetAttrib mr-es335 1 I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted December 8, 2023 Share Posted December 8, 2023 (edited) in order for it to work normally, and to get the information from the desktop.ini you need update the attributes οf the dir to read only (if it doesn't already have it) Edit: I updated the code Edit: also pay attention to the parameters $iRecur, $iReturn of the _FileListToArrayRec() function Edited December 8, 2023 by ioa747 mr-es335 1 I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted December 8, 2023 Author Share Posted December 8, 2023 (edited) ioa747, Thanks for this...appreciated! To simply this sampling so that can understand what is all going on, I did the following: ; https://www.autoitscript.com/forum/topic/211214-cmd-to-autoit/#comment-1527768 #include <File.au3> _FindAllFiles() ;---------------------------------------------------------------------------------------- Func _FindAllFiles() Local $oldPath = "D:\" Local $newPath = "E:\" Local $Folder $ArraySrtfiles = _FileListToArrayRec($oldPath, "Desktop.txt", $FLTAR_FILES, $FLTAR_RECUR) If Not IsArray($ArraySrtfiles) Then ConsoleWrite($oldPath & " = Invalid input path" & @CRLF) Return Else For $x = 1 To $ArraySrtfiles[0] ConsoleWrite($oldPath & $ArraySrtfiles[$x] & " -> " & $newPath & $ArraySrtfiles[$x] & @CRLF) FileCopy($oldPath & $ArraySrtfiles[$x], $newPath & $ArraySrtfiles[$x], 1) $Folder = StringLeft($newPath & $ArraySrtfiles[$x], StringInStr($newPath & $ArraySrtfiles[$x], '\', 0, -1)) ;FileSetAttrib($Folder, "+R") Next EndIf EndFunc ;==>_FindAllFiles Observations 1) I created a folder : D:\Main which contains five sub-folders [First, Second...and so on] • Each of the five folders contains a "desktop.txt" 2) I then created the same folders on E: - without the text files 3) The following is the Console output: All that I can say, ioa747, s "Wow!"... and "Double Wow!" • Now if I can only understand what you have written?! Thanks again! Appreciated! Edited December 8, 2023 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted December 8, 2023 Share Posted December 8, 2023 (edited) for a better simulation, in the folders you made in d:\main change the folder icons, this has the effect of creating desktop.ini in each folder when you run the script, then the folder icons inside the E folder will also change here you need update the attributes οf the dir to read only - remove the ; from ;FileSetAttrib($Folder, "+R") and change from "Desktop.txt" to "Desktop.ini" Edited December 8, 2023 by ioa747 mr-es335 1 I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted December 8, 2023 Author Share Posted December 8, 2023 (edited) ioa747,So, I did as you suggested and all worked out "great!!!" • Now, If I can only figure out what you have done! Thanks again ioa747...very much appreciated! Edited December 8, 2023 by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
mr-es335 Posted December 9, 2023 Author Share Posted December 9, 2023 (edited) Test Edited December 9, 2023 by mr-es335 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