Sign in to follow this  
Followers 0
harvester2001

start 20 downloads in one time (loop)

1 post in this topic

Hi I need your help :)

I need download backup from 200 remote pc. I calculate that I can download 20 backups in one time. I need to create loop, take localizations from txt file and start 20 downloads in one time (i want use ShellExecute and robocopy), after finish one from running 20 take another localizations from txt file until localizations finish. And I need trigger if is 7:00 pause script. I hope you know what I mean :)

Many thanks for help, sorry for my english.

This is what I got:

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>

Local $targets = @ScriptDir& "\targets.txt"
Local $log_name = "\autoit.log"

MsgBox($MB_SYSTEMMODAL, "", "start copy", 1)


Example()

Func Example()

   If Not FileExists($targets) Then
      MsgBox($MB_SYSTEMMODAL, "", "The file targets.txt - doesn't exist!")
      Exit
   EndIf

   FileOpen($targets, 0)
   Global $arr[1000]
   ReDim $arr[_FileCountLines($targets)+1]

   For $i = 1 to _FileCountLines($targets)
       $line = FileReadLine($targets, $i)
       $arr[$i] = $line

      ; Check if is online
      Local $iPing = Ping($arr[$i], 250)
      If $iPing Then
         ; ONLINE
         $rc = FileCopy("\\"&$arr[$i]&"\e$\backup\", @ScriptDir&"\downloads\"&$arr[$i]&"\", $FC_CREATEPATH)

         If $rc = 0 Then
            _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" ONLINE error")
         Else
            _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" ONLINE done")
         EndIf
      Else
         ;OFFLINE
        _FileWriteLog(@ScriptDir & $log_name, $arr[$i]&" OFFLINE")
      EndIf
   Next


EndFunc   ;==>Example

MsgBox($MB_SYSTEMMODAL, "", "Finish downloads backups")
Exit

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Szmycu
      Ending Loop When found Pixel Color
      By Szmycu
      Hello i Have HP Bar in my game and it has 170px of width and then im gonna find start of this by mouse pos then i got $hpStart[0] = 661  $hpStart[1] = 230 ,  $hpEnd[0] = 839
      And there is from $hpStart[0] = 661 the same color - 0xCB423B but depends of my points of hp for example on pixel  $hpStart[0] = 745 would be another color not  0xCB423B and then i will know my my character got 50% of health points.
       
      I encountered problem here - for loop still looping to 839 and not founding this change in color for example on pixel $hpStart[0] = 745
      I would know actual $i counter and $hpEnd[0] then only i can calculate current health percent value 
       
      Please help me how to achieve that! Thanks for any help
       
      Func MouseCord() $MousePos = MouseGetPos() global $hpStart = $MousePos global $hpEnd = $hpStart $hpEnd[0] = $hpEnd[0] + 170 For $i = $hpStart[0] To $hpEnd[0] ; Looping from 661 to 839 $pixel = PixelGetColor($i,$hpStart[1]) If $pixel <> 0xCB423B Then $hpNowPer = ( $hpEnd[0] - $i ) / 170 $hpPoOdjeciu = 1 - $hpNowPer $hpNowPercent = Round($hpPoOdjeciu,2) ExitLoop ; - that not working EndIf Next EndFunc  
       
    • Revelation343
      Mailing from Excel/variable storing
      By Revelation343
      Purpose of script: To send emails in Outlook based on data in an excel spreadsheet. From: fields are entered for purposes of sending on behalf of (delegate), copies A2 cell from excel for To: field, Subject field is a static value and entered, returns to excel spreadsheet to read A1 and copy the first name and insert into the body of a template at an insertion point. The From, and the body of the email change based on region, so currently I have 6 different scripts that do essentially the same thing with some minor changes and want to consolidate into one script to save time.
      Question:
      To expedite the process of this and cut down on the amount of scripts, 6 in total I use daily, is it possible for me to somehow add the region to column C in excel, have autoit read column C values per row, and then decide which function, within a master script, to execute and loop this until there is no value in column C field?
      Example spreadsheet:
      Rob | rob@annuity.com |Midwest
      Annie | annie@agency.com | Midwest
      Kyle | kyle@agency.com | MidAtlantic
      Rick | rick@megasales.com | MidAtlantic
      Blank | Blank | Blank |
      Example execution:
      Run Birthday.au3, execute loop part through hotkey
      Reads row 1, C1, value is Midwest, calls Midwest(), script runs as Midwest Birthday.au3 does currently
      Reads row 2, C2, value is Midwest, calls Midwest(), script runs as Midwest Birthday.au3 does currently
      Reads row 3, C3, value is MidAtlantic, calls MidAtlantic(), script runs as MidAtlantic Birthday.au3 currently
      Reads row 4, C4, value is MidAtlantic, calls MidAtlantic(), script runs as MidAtlantic Birthday.au3 currently
      Reads row 5, C5, value is null or blank, ends script through Exit
       
      Everything I have coded in my time in AutoIt has been based mostly on mouse based movements and I don't have variable programming knowledge so I feel like I'm close to understanding how to do this, but the reading/storing variables part is beyond my current skill set. Help is appreciated.
      Mail Merges don't work as delegated in Outlook 07, for those that might be questioning why I just don't do that.
       
      MidAtlantic Birthday.au3
      Midwest Birthday.au3
    • digitalexpl0it
      Help with Nested For loop
      By digitalexpl0it
      Hello,
       
      I am trying to updated a autoit app that moves files from one location to another. What Ia m trying to do is exclude specified sub directories from being moved/copied or files within the sub-folders
      As of now the code doesn't want to execute the nested for loop 
       
      Global $szDrive, $szDir, $szFName, $szExt Global $File = "*" func File_mover($Src,$File,$Dst) ; GET DIRECTORY EXCLUDES ; ###################### ; Create blank 2 dem array Local $ExArray[0][1] ; load ini file Local Const $sFilePath = "exclude.ini" ; Check to see if ini exists Local $iFileExists = FileExists($sFilePath) ; If the INI file is not found, output error message If not $iFileExists Then msgbox(0,"Oh NO!", $sFilePath & " not found!") endif ; Read ini file Local $aArray = IniReadSection($sFilePath, "test") ; Start the array loop If Not @error Then for $i = 1 to $aArray[0][0] ; Add Ini values into array _ArrayAdd($ExArray, $aArray[$i][1]) next endif ; Display array ;_ArrayDisplay($ExArray, "test Label") ProgressOn("Moving Scanned File(s)", "Moving scans into citrix...", "0%") $aFiles = _FileListToArray3($Src, $File, 1, 1, 0, 0) For $i = 1 To $aFiles[0] call("_PathSplit",$aFiles[$i], $szDrive, $szDir, $szFName, $szExt) $SrcFile = $Src & "\" & $szDrive & $szDir & $szFName & $szExt $DstFile = $Dst & "\" & $szDir & $szFName & $szExt $NumFiles = DirGetSize($Src,1) ; If File Exsists copy and rename file If FileExists($DstFile) Then $DstFile = call("_IfIdenticalIncrement", $SrcFile, $DstFile) If $DstFile <> "" Then For $ii = $NumFiles[1] To 100 Step 10 ProgressSet($ii, $ii & "%","Moving Files...") ; Move Scans ; List Dir in srouce dir $dirEx = _FileListToArray($Src,"*",2) If UBound($dirEx) > 1 Then ; Look in the dir list array For $dir In $dirEx ; Find and compaire dir in exclude array For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next FileMove($SrcFile, $DstFile, 8) Next endif Sleep(100) Next EndIf ; File doesnt exists so copy the file over Else For $ii = $NumFiles[1] To 100 Step 10 ProgressSet($ii, $ii & "%","Moving Files...") ; Move Scans ; List Dir in srouce dir $dirEx = _FileListToArray($Src,"*",2) If UBound($dirEx) > 1 Then ; Look in the dir list array For $dir In $dirEx ; Find and compaire dir in exclude array For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next FileMove($SrcFile, $DstFile, 8) Next endif Sleep(100) next EndIf ProgressSet(100, "Scans Moved...Successfully!", "Done!") sleep(2000) ProgressOff() Next endfunc Func _IfIdenticalIncrement($vSrcFile, $vDstFile) Local $Count = 0 ; Get the modified date of the source file. $ScrVer = FileGetTime($vSrcFile, 0, 1) ; To get all elemnt of the distination file (in plan to add incremental number). call("_PathSplit",$vDstFile, $szDrive, $szDir, $szFName, $szExt) ; Loop to increment the name of the file. While FileExists($vDstFile) $Count += 1 $vDstFile = $szDrive & $szDir & $szFName & "(" & $Count & ")" & $szExt WEnd ; If file(1), it assume that is the first copy. If $Count = 1 Then Return $vDstFile ; If file(x-1) is identical then assume the file is already duplicated. ElseIf $ScrVer = FileGetTime($szDrive & $szDir & $szFName & "(" & $Count - 1 & ")" & $szExt, 0, 1) Then Return "" ; Else assume it is a new version. Else Return $vDstFile EndIf EndFunc ;==>_IfIdenticalIncrement  
       
      This part is skipped and not sure why
       
      For $exclude In $ExArray If ($dir = $exclude) Then ; if exclude dir found go to top loop and skip ContinueLoop 2 EndIf Next INI file is this
       
      [test] EXCLUDE1=test1 EXCLUDE2=test2 EXCLUDE3=test3  
    • Jcreator
      array vs loop is this possible
      By Jcreator
      i have a file flower.txt with the name of the flowers and there picture location and information about that kind of flower. i wana cerat a gui that will display the flower picture and it information 
      here is the script 
      #include <Misc.au3> #include <EditConstants.au3> #include <Constants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <GuiComboBox.au3> #include <GuiTab.au3> #include <file.au3> #include <array.au3> Global $sfPath = 'flowers.txt' Global $aFlowers _FileReadToArray($sfPath,$aFlowers,$FRTA_NOCOUNT,'|') _ArrayColDelete($aFlowers,0) ;row 0 has no data so deleting $Form1 = GUICreate("Search Flower Name",320, 480) $input = GUICtrlCreateInput("", 60, 360, 209, 25) $idss = GUICtrlCreateButton("Search", 130, 400, 73, 65) GUISetState(@SW_SHOW) Func Searchf() Global $Fname = GUICtrlRead($input) For $iNo = 0 To UBound($aFlowers[0][0]) - 1 ; if $Fname = $aFlowers[$iNo][0] then MsgBox($MB_SYSTEMMODAL, "","Flower nfo", ""& $aFlowers[$iNo][1] &"") pic() EndIf Next EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $nMsg = $idss Searchf() EndSwitch WEnd func pic() For $iNo = 0 To UBound($aFlowers[0][0]) - 1 GUICtrlCreatePic($aFlowers[$iNo][2], 20, 30, 280, 280) Next EndFunc here is the flower.txt file
      |Hibiscus|Hibiscus is a hardy perennial which grows in variety of colors, sizes and fragrances. Actually they are tropical flowers which require ample sunlight and moisture to grow well. These flowers start blooming in late spring and continuously bloom through July and August.|C:\T-in\IMG\2.jpg |Lilies|There are different types of lily flowers which bloom in August including water lilies, tiger lilies and gold band lilies. Tiger lilies generate orange flowers having black spots. This lily blooms in delayed July and beginning of August. Gold band lily produce exotic white blooms. All varieties of lilies need enough space to grow and protection from summer sun.|C:\T-in\IMG\1.jpg |Turtlehead|Growing in humid areas, turtleheads are small flowers which bloom from July to September. They mostly produce flowers of white and pink color.|C:\T-in\IMG\3.jpg |Hydrangea|These are ever green bushes which produce flowers in different colors including white, purple, blue and pink. They are easy to grow bushes and can grow 3 to 10 feet tall. They require morning sun to grow but they should be protected from noon and afternoon sun.|C:\T-in\IMG\4.jpg |Dahlias|August proves to be the peak blooming season for dahlias. Dahlias come in colors like white, orange, yellow, red and purple. They can tolerate all types of soil and require full sun to grow.|C:\T-in\IMG\5.jpg am still trying to learn about how the ubound work and the _filereadtoarray
    • Jcreator
      this script keeps having contradicting loop
      By Jcreator
      i used this code to take names for a text file called data and put the info of the image and it location from the data file into the gui interface but it only detect the lines with the info and it do not show the images . here is the code 
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <GuiComboBox.au3> #include <GuiTab.au3> #include <file.au3> #include <array.au3> _Main() Func _Main() Local $idTab1 $Form1 = GUICreate("Form1", 500, 334, 240, 182) $Group1 = GUICtrlCreateGroup("Group1", 20, 12, 249, 314) $idButton6 = GUICtrlCreateButton("Info", 50, 270, 185, 49) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) Global $fileMPA = "C:\T-in\MPA\data.txt" FileOpen($fileMPA, 0)    Global $line1 = FileReadLine($fileMPA , 1) $imp = 0 $idTab1 = GUICtrlCreateTab(300, -3, 180, 330) GUICtrlCreateTabItem("imglist1") GUICtrlSetTip(-1, '#Region TAB1') GUICtrlSetTip(-1, '#Region LIST') Local $imglist1 = GUICtrlCreateList("", 307, 26, 164, 304) $cline =_FileCountLines($fileMPA)  While  $imp < $cline $line2 = FileReadLine($fileMPA , $imp + 2)  $imp = $imp + 7 if $line2 = ""  then     ExitLoop    else  GUICtrlSetData(-1, ""& $line2 &"", "")  endif WEnd GUICtrlCreateTabItem("imagelist2") GUICtrlSetTip(-1, '#Region TAB2') GUICtrlCreateTabItem("imagelist3") GUICtrlSetTip(-1, '#Region TAB3') While 1     $Msg = GUIGetMsg()     Select         Case $Msg = $GUI_EVENT_CLOSE             Exit             Global $whatnow = GUICtrlRead($imglist1) Case $Msg = $idButton6             $imp2 = 0              While  $imp2 < 30 $line2 = FileReadLine($fileMPA ,$imp2 + 2) $line3 = FileReadLine($fileMPA , $imp2 + 3) $line7 = FileReadLine($fileMPA , 7)  $imp2 = $imp2 + 7 if $line2 = ""  then  ExitLoop             If GUICtrlRead($imglist1) = ""& $line2 &""  Then MsgBox($MB_SYSTEMMODAL, "img info" , $line3)                WEnd             EndSelect $imp2 = 0              While  $imp2 < 30 $line2 = FileReadLine($fileMPA ,$imp2 + 2) $line3 = FileReadLine($fileMPA , $imp2 + 3) $line7 = FileReadLine($fileMPA , 7)  $imp2 = $imp2 + 7     Select Case GUICtrlRead($imglist1) = ""& $line2 &"" if $line2 = "" then ExitLoop     $Pic1 = GUICtrlCreatePic(""& $line7 &"", 185, 28, 233, 230) If GUICtrlRead($imglist1) then  ExitLoop EndSelect WEnd     WEnd  EndFunc   ;==>_Main the data.txt file content is 
      Hibiscus Hibiscus is a hardy perennial which grows in variety of colors, sizes and fragrances. Actually they are tropical flowers which require ample sunlight and moisture to grow well. These flowers start blooming in late spring and continuously bloom through July and August. C:\T-in\IMG\2.jpg Lilies There are different types of lily flowers which bloom in August including water lilies, tiger lilies and gold band lilies. Tiger lilies generate orange flowers having black spots. This lily blooms in delayed July and beginning of August. Gold band lily produce exotic white blooms. All varieties of lilies need enough space to grow and protection from summer sun. C:\T-in\IMG\1.jpg Turtlehead Growing in humid areas, turtleheads are small flowers which bloom from July to September. They mostly produce flowers of white and pink color. C:\T-in\IMG\3.jpg Hydrangea These are ever green bushes which produce flowers in different colors including white, purple, blue and pink. They are easy to grow bushes and can grow 3 to 10 feet tall. They require morning sun to grow but they should be protected from noon and afternoon sun. C:\T-in\IMG\4.jpg Dahlias August proves to be the peak blooming season for dahlias. Dahlias come in colors like white, orange, yellow, red and purple. They can tolerate all types of soil and require full sun to grow.