Jump to content

check if more than one file exists


legend
 Share

Recommended Posts

something like

$bFileOne = FileExists ("file")
$bFileTwo = FileExists ("file")
If $bFileOne And $bFileTwo Then
 ; some action
ElseIf $bFileOne And ( Not $bFileTwo ) Then
 ; some action
ElseIf ( Not $bFileOne ) And $bFileTwo Then 
 ; some action
Else
 ; None of the files exist
EndIf
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

$bFileOne = FileExists ("file")
$bFileTwo = FileExists ("file")
If $bFileOne And $bFileTwo Then
; Both Files Exist
;Now Do Something
ElseIf $bFileOne And ( Not $bFileTwo ) Then
; File Two Doesnt Exist
; DO whatever you want
ElseIf ( Not $bFileOne ) And $bFileTwo Then
; File One Doesnt Exist
Else
; None of the files exist
EndIf

Your Question has already been answered

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Doing between 2 and 6 compares (3 compound If/Then statements) is not very efficient when only 2 compares are needed:

$sResult1 = FileExists("C:test1.txt")
$sResult2 = FileExists("C:test2.txt")

If $sResult1 Then
    If $sResult2 Then
     ; do what I do when both 1 and 2 exist
    Else
        ; do what I do when only 1 exists
    EndIf
Else
    If $sResult2 Then
     ; do what I do when only 2 exists
    Else
     ; do what i do when neither 1 or 2 exist
    EndIf
EndIf

; a sneakier option
$sResult = FileExists("C:test1.txt")
$sResult += FileExists("C:test2.txt") * 2

Switch $sResult
   Case 0
        ; do what i do when neither 1 or 2 exist
    Case 1
     ; do what I do when only 1 exists
    Case 2
     ; do what I do when only 2 exists
    Case 3
     ; do what I do when both 1 and 2 exist
EndSwitch

typo

Edited by Spiff59
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...