break on
call @ScriptDir + "\dirlist.udf"
call @ScriptDir + "\dirplus.udf"
call @ScriptDir + "\msg.udf"
call @ScriptDir + "\copyfiles.udf"
call @ScriptDir + "\readexcel2.udf"
$Brandshop = readexcel2(@Scriptdir + '\pccs.xlsx',,-1,-1)
If @ERROR = "2" ; pcc spreadsheet is required - die if not provided
? 'ERROR OCCURED: @serror (@error)' @CRLF @CRLF
Quit 1
EndIf
; Get the source, dest & brand args specified on the command-line
; get the command line as an array - elements 0 & 1 are the kix.exe and the script.kix items
$aCmdLine = GetCommandLine(1)
; scan the array looking for the source arg
$ = AScan($aCmdLine, '--s:', , , 1) ; get SOURCE arg
If $ > 1 ;
$Source = SubStr($aCmdLine[$], 5)
Else ; arg is required - die if not provided
'ERROR: Source was not specified!' @CRLF @CRLF
'Usage: myscript.kix --s:Source_path --d:destination_path --b:brand' @CRLF
Quit 1
EndIf
; scan the array looking for the destination arg
$ = AScan($aCmdLine, '--d:', , , 1) ; get destination arg
If $ > 1 ;
$Dest = SubStr($aCmdLine[$], 5)
Else ; arg is required - die if not provided
'ERROR: Destination was not specified!' @CRLF @CRLF
'Usage: myscript.kix --s:Source_path --d:destination_path --b:brand' @CRLF
Quit 1
EndIf
; scan the array looking for the brand arg
$ = AScan($aCmdLine, '--b:', , , 1) ; get brand type
If $ > 1 ;
$Brand = SubStr($aCmdLine[$], 5)
Else ; arg is required - die if not provided
'ERROR: Brand was not specified or was invalid!' @CRLF @CRLF
'Usage: myscript.kix --s:Source_path --d:destination_path --b:brand' @CRLF
Quit 1
EndIf
$destdirs = Dir($dest + "\*")
While $destdirs <> "" and @Error = 0
For $rowcount = 0 to ubound($Brandshop)
Select
Case $Brand = $Brandshop[$rowcount,1] and $destdirs = $Brandshop[$rowcount,0]
$copycentral = CopyFiles($Source,$Dest + "\" + $destdirs,0,1)
Case $Brand = "ALL" and $destdirs = $Brandshop[$rowcount,0]
$copycentral = CopyFiles($Source,$Dest + "\" + $destdirs,0,1)
Case 1
EndSelect
Next
$destdirs = Dir()
Loop
exit