Jump to content

cmd to AutoIt


 Share

Go to solution Solved by ioa747,

Recommended Posts

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

Example.png.3d7d7b72bbccfe80c6abca0375243147.png:

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Solution

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 by ioa747
Added FileSetAttrib

I know that I know nothing

Link to comment
Share on other sites

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 by ioa747

I know that I know nothing

Link to comment
Share on other sites

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:
Output.thumb.png.c0b126f7c3b24fa89c24fb60f5ea775c.png

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 by mr-es335
Link to comment
Share on other sites

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 by ioa747

I know that I know nothing

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...