Jump to content

Recommended Posts

Posted (edited)

Hi guys,

with help of M23 now i have this script:

$Path = GUICtrlRead($FolderInput)
$Pre = @TempDir & "\Test.exe"
$Command = "-e -p"
$Folders= _FileListToArray($Path, '*', 1)
$Folders[0] = "@echo off" & @CRLF

$fFlag = ""
AdlibRegister("Update",333)
For $i = 1 To UBound($Folders) - 1
If RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & $Password & " " & '"' & $Path & "\" & $Folders[$i] & '"', @TempDir, @SW_HIDE) = 0 Then
ConsoleWrite("Information - Success")
    Else
        $fFlag &= $i & "|"
    EndIf
    ConsoleWrite("Information - Fail")
  
Next
If $fFlag = "" Then
If GUICtrlRead($FolderCheckboxCrypt) = $GUI_CHECKED Then
  Func()
EndIf
FileDelete(@TempDir & "\Test.txt")
MsgBox(0, "Information","OK")
Else
    $aFailed = StringSplit($fFlag, "|")
    $sMsg = "Error:" & @CRLF & @CRLF
    For $i = 1 To $aFailed[0] - 1
        $sMsg &= $Folders[$aFailed[$i]] & @CRLF
    Next
FileDelete(@TempDir & "\Test.exe")
    MsgBox(16, "Error", $sMsg)
EndIf
AdlibUnRegister("Update")
WinSetTitle($GUI,"","Test name")
EndFunc

From option of _FileListToArray i see you can select exstension to process by array, ad example *.txt

But i don' find something to exclude an extension from array.

Someone can resolve this doubt?

Thanks to all for support, i'll grateful to this forum :)

Edited by johnmcloud
  • Moderators
Posted

johnmcloud,

Look at the RecFileListToArray UDF in my sig - it allows you to include/exclude multiple options. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

Thanks Melba, but somethig is wrong becouse file will be not processed.

I have change only this part with helper ( i have test it and esclude the extension )

#include <RecFileListToArray.au3>

$Folders= _RecFileListToArray($Path, "*.*", 1, 0, 0, 2, "*.txt", "")

I don't have error, but the file will be not processed

Edited by johnmcloud
  • Moderators
Posted

johnmcloud,

  Quote

the file will be not processed

I do not understand what you mean. When I run your snippet I get the all the files from the folder (less the excluded ones) in the returned array. :)

And why do you call the array $Folders when you are asking for files only to be returned? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

$Path = GUICtrlRead($FolderInput)
$Pre = @TempDir & "Test.exe"
$Command = "-e -p"
$Folders= _RecFileListToArray($Path, "*.*", 1, 0, 0, 2, "*.txt", "")
$Folders[0] = "@echo off" & @CRLF
$fFlag = ""

AdlibRegister("Update",333)
For $i = 1 To UBound($Folders) - 1
If RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & $Password & " " & '"' & $Path & "" & $Folders[$i] & '"', @TempDir, @SW_HIDE) = 0 Then
ConsoleWrite("Information - Success")
    Else
        $fFlag &= $i & "|"
    EndIf
    ConsoleWrite("Information - Fail")

Next
If $fFlag = "" Then
If GUICtrlRead($FolderCheckboxCrypt) = $GUI_CHECKED Then
  Func()
EndIf
FileDelete(@TempDir & "Test.txt")
MsgBox(0, "Information","OK")
Else
    $aFailed = StringSplit($fFlag, "|")
    $sMsg = "Error:" & @CRLF & @CRLF
    For $i = 1 To $aFailed[0] - 1
        $sMsg &= $Folders[$aFailed[$i]] & @CRLF
    Next
FileDelete(@TempDir & "Test.exe")
    MsgBox(16, "Error", $sMsg)
EndIf
AdlibUnRegister("Update")
WinSetTitle($GUI,"","Test name")
EndFunc

Is the same code, with the _FileListToArray($Path, '*', 1) work fine but process all file, with _RecFileListToArray don't process any file ( and give me msgbox "OK" )

For the name $folders... it's copy past code, in the same script it process folder and i forget to reneame :)

Edited by johnmcloud
  • Moderators
Posted

johnmcloud,

Use _ArrayDisplay and see what difference there is between the arrays returned by _FileListToArray and _RecFileListToArray. :)

Using $iReturnPath = 2 you are getting the "Full path" for the files returned by _RecFileListToArray. So I believe you will no longer need to add the path again in your RunWait line. Or you could use $iReturnPath = 1 to get the "Relative path" as returned by _FileListToArray. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

  On 1/3/2012 at 2:16 PM, 'Melba23 said:

johnmcloud,

Use _ArrayDisplay and see what difference there is between the arrays returned by _FileListToArray and _RecFileListToArray

Yeah, there is a difference of path, you have right, i'm too noob :)

I have change this:

$Folders= _RecFileListToArray($Path, "*.*", 0, 0, 0, 1, "*.txt", "")

It processed two time the path in cmd, i'll set the relative now.

Thanks for support Melba and for UDF

Edited by johnmcloud
  • Moderators
Posted

johnmcloud,

Glad I could help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
×
×
  • Create New...