Sign in to follow this  
Followers 0
n9mfk9

select case ?

4 posts in this topic

Hi everyone,

I have a select case question

my first select is there away to put them together so it wood check the

file copy an file size or do they need to be two like i have them thanks

#Include <File.au3>
#Include <Array.au3>
Global $text1, $text2
$FileOut = 'C:\new\error.txt'
$originalDir = 'C:\wdisplay\'
$destinationDir = 'C:\new\wd19'

FileClose(FileOpen($FileOut, 2))
DirCreate($destinationDir)
$status = ''
$FileList = _FileListToArray($originalDir, "**", 1)
$FolderList = _FileListToArray($originalDir, '**', 2)
If @error = 1 Then
MsgBox(0, "", "No Files\Folders Found.")
Exit
EndIf
;_ArrayDisplay($FileList,"$FileList")
_ArrayDisplay($FolderList,'$FolderList')
For $n = 1 To $FileList[0]
$Filetest = FileCopy($originalDir&$FileList[$n],$destinationDir&'/',8)
; MsgBox(0,"",$originalDir&'\'&$FileList[$n]&$destinationDir&'/' )
Select
Case $Filetest = 1
$Filetest = "OK"
Case $Filetest = 0
$Filetest = "error"
EndSelect
Select
Case FileGetSize( $originalDir&$FileList[$n] )== FileGetSize(
$destinationDir&'\'&$FileList[$n])
MsgBox(0,"1", 'ok' )
EndSelect
;MsgBox(0,"1", ))
$text1 &= $originalDir & $FileList[$n] & ' -> ' & $destinationDir &
$FileList[$n] & ' ' & $Filetest & @CRLF
;MsgBox(0,"",FileGetSize( $destinationDir&'\'&$FileList[$n]))
Next
FileWrite($FileOut, $text1)
For $n = 1 To $FolderList[0]
$DirTest =
DirCopy($originalDir&$FolderList[$n],$destinationDir&'\'&$FolderList[$n],0)
Select
Case $DirTest = 1
$DirTest = "OK"
Case $DirTest = 0
$DirTest = "error"
EndSelect
$text2 &= $originalDir & $FolderList[$n] & ' -> ' & $destinationDir
& $FolderList[$n] & ' ' & $DirTest & @CRLF
;MsgBox(0,"", $text2)
Next
FileWrite($FileOut, $text2)

Share this post


Link to post
Share on other sites



1. Switch / EndSwitch is cleaner

2. If the FileCopy is successful why are you verifying it by comparing the source and destination sizes?

#Include <File.au3>
#Include <Array.au3>
Global $text1, $text2
$FileOut = 'C:\new\error.txt'
$originalDir = 'C:\wdisplay\'
$destinationDir = 'C:\new\wd19'

FileClose(FileOpen($FileOut, 2))
DirCreate($destinationDir)
$status = ''
$FileList = _FileListToArray($originalDir, "**", 1)
$FolderList = _FileListToArray($originalDir, '**', 2)

If @error Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

;_ArrayDisplay($FileList,"$FileList")
_ArrayDisplay($FolderList, '$FolderList')

For $n = 1 To $FileList[0]
    $Filetest = FileCopy($originalDir & $FileList[$n], $destinationDir & '/', 8)
    ; MsgBox(0,"",$originalDir&'\'&$FileList[$n]&$destinationDir&'/' )
    Switch $Filetest
        Case 1
            $Filetest = "OK"
        Case 0
            $Filetest = "error"
    EndSwitch
    
    Select
        Case FileGetSize($originalDir & $FileList[$n]) == FileGetSize(
            $destinationDir & '\' & $FileList[$n])
            MsgBox(0, "1", 'ok')
    EndSelect
    ;MsgBox(0,"1", ))
    $text1 &= $originalDir & $FileList[$n] & ' -> ' & $destinationDir & $FileList[$n] & ' ' & $Filetest & @CRLF
    ;MsgBox(0,"",FileGetSize( $destinationDir&'\'&$FileList[$n]))
Next

FileWrite($FileOut, $text1)

For $n = 1 To $FolderList[0]
    $DirTest = DirCopy($originalDir & $FolderList[$n], $destinationDir & '\' & $FolderList[$n], 0)
    
    Switch $DirTest
        Case 1
            $DirTest = "OK"
        Case 0
            $DirTest = "error"
    EndSwitch
    $text2 &= $originalDir & $FolderList[$n] & ' -> ' & $destinationDir & $FolderList[$n] & ' ' & $DirTest & @CRLF
    ;MsgBox(0,"", $text2)
Next

FileWrite($FileOut, $text2)

Share this post


Link to post
Share on other sites

hi weaponx,

what i was looking for is there away to way to do file check an size check wit out doing 2 select

thanks

1. Switch / EndSwitch is cleaner

2. If the FileCopy is successful why are you verifying it by comparing the source and destination sizes?

#Include <File.au3>
#Include <Array.au3>
Global $text1, $text2
$FileOut = 'C:\new\error.txt'
$originalDir = 'C:\wdisplay\'
$destinationDir = 'C:\new\wd19'

FileClose(FileOpen($FileOut, 2))
DirCreate($destinationDir)
$status = ''
$FileList = _FileListToArray($originalDir, "**", 1)
$FolderList = _FileListToArray($originalDir, '**', 2)

If @error Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

;_ArrayDisplay($FileList,"$FileList")
_ArrayDisplay($FolderList, '$FolderList')

For $n = 1 To $FileList[0]
    $Filetest = FileCopy($originalDir & $FileList[$n], $destinationDir & '/', 8)
    ; MsgBox(0,"",$originalDir&'\'&$FileList[$n]&$destinationDir&'/' )
    Switch $Filetest
        Case 1
            $Filetest = "OK"
        Case 0
            $Filetest = "error"
    EndSwitch
    
    Select
        Case FileGetSize($originalDir & $FileList[$n]) == FileGetSize(
            $destinationDir & '\' & $FileList[$n])
            MsgBox(0, "1", 'ok')
    EndSelect
    ;MsgBox(0,"1", ))
    $text1 &= $originalDir & $FileList[$n] & ' -> ' & $destinationDir & $FileList[$n] & ' ' & $Filetest & @CRLF
    ;MsgBox(0,"",FileGetSize( $destinationDir&'\'&$FileList[$n]))
Next

FileWrite($FileOut, $text1)

For $n = 1 To $FolderList[0]
    $DirTest = DirCopy($originalDir & $FolderList[$n], $destinationDir & '\' & $FolderList[$n], 0)
    
    Switch $DirTest
        Case 1
            $DirTest = "OK"
        Case 0
            $DirTest = "error"
    EndSwitch
    $text2 &= $originalDir & $FolderList[$n] & ' -> ' & $destinationDir & $FolderList[$n] & ' ' & $DirTest & @CRLF
    ;MsgBox(0,"", $text2)
Next

FileWrite($FileOut, $text2)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#Include <File.au3>
#Include <Array.au3>
Global $text1, $text2
$FileOut = 'C:\new\error.txt'
$originalDir = 'C:\wdisplay\'
$destinationDir = 'C:\new\wd19'

FileClose(FileOpen($FileOut, 2))
DirCreate($destinationDir)
$status = ''
$FileList = _FileListToArray($originalDir, "**", 1)
$FolderList = _FileListToArray($originalDir, '**', 2)

If @error Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

;_ArrayDisplay($FileList,"$FileList")
_ArrayDisplay($FolderList, '$FolderList')

For $n = 1 To $FileList[0]
    $Filetest = FileCopy($originalDir & $FileList[$n], $destinationDir & '/', 8)
    ; MsgBox(0,"",$originalDir&'\'&$FileList[$n]&$destinationDir&'/' )
    Switch $Filetest
        Case 1
            $Filetest = "OK"
            If (FileGetSize($originalDir & $FileList[$n]) == FileGetSize($destinationDir & '\' & $FileList[$n])) Then
                MsgBox(0, "1", 'ok')
EndIf
        Case 0
            $Filetest = "error"
    EndSwitch
    
    ;MsgBox(0,"1", ))
    $text1 &= $originalDir & $FileList[$n] & ' -> ' & $destinationDir & $FileList[$n] & ' ' & $Filetest & @CRLF
    ;MsgBox(0,"",FileGetSize( $destinationDir&'\'&$FileList[$n]))
Next

FileWrite($FileOut, $text1)

For $n = 1 To $FolderList[0]
    $DirTest = DirCopy($originalDir & $FolderList[$n], $destinationDir & '\' & $FolderList[$n], 0)
    
    Switch $DirTest
        Case 1
            $DirTest = "OK"
        Case 0
            $DirTest = "error"
    EndSwitch
    $text2 &= $originalDir & $FolderList[$n] & ' -> ' & $destinationDir & $FolderList[$n] & ' ' & $DirTest & @CRLF
    ;MsgBox(0,"", $text2)
Next

FileWrite($FileOut, $text2)

Edited by weaponx

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