Func _PathSplitEx($sFilePath, ByRef $sDrive, ByRef $sDir, ByRef $sParentDir, ByRef $sFileName, ByRef $sExtension)
Local $aReturn[6] = [$sFilePath], $fAppended = True, $iExtension = StringInStr($sFilePath, '.', 2, -1), $iSlash = 0
If StringInStr($sFilePath, '/', 2) Then
$sFilePath = StringReplace($sFilePath, '/', '\') ; Replace '/' with '\'
EndIf
$aReturn[2] = $sFilePath
$aReturn[1] = StringLeft($sFilePath, 2) ; Drive.
If $aReturn[1] == '\\' Then ; UNC path.
$iSlash = StringInStr($sFilePath, '\', 2, 3)
If $iSlash Then
$aReturn[1] = StringLeft($sFilePath, $iSlash - 1)
EndIf
$aReturn[2] = 'A:' & StringTrimLeft($aReturn[2], StringLen($aReturn[1]))
$iExtension = StringInStr($aReturn[2], '.', 2, -1)
EndIf
$iSlash = StringInStr($aReturn[2], '\', 2, -1)
If $iExtension Then ; If an extension exists.
$aReturn[5] = StringTrimLeft($aReturn[2], $iExtension - 1) ; Extension.
$aReturn[4] = StringTrimRight(StringTrimLeft($aReturn[2], $iSlash), StringLen($aReturn[5])) ; Filename.
Else
$fAppended = (StringRight($aReturn[2], 1) == '\') ; Check if a backslash is appendend to the end.
If Not $fAppended Then ; If backslash doesn't exist (when it's a directory) then append to the end.
$aReturn[2] &= '\'
$iSlash = StringInStr($aReturn[2], '\', 2, -1)
EndIf
EndIf
$aReturn[2] = StringTrimLeft(StringLeft($aReturn[2], $iSlash), 2) ; Path.
$aReturn[3] = StringTrimLeft($aReturn[2], StringInStr($aReturn[2], '\', 2, -2)) ; Parent folder.
$aReturn[2] = StringTrimRight($aReturn[2], StringLen($aReturn[3])) ; Remove parent folder from the path.
If Not $fAppended Then
$aReturn[3] = StringTrimRight($aReturn[3], 1)
EndIf
If $aReturn[2] == '\' Then ; If no folder is present then copy the contents of the parent folder.
$aReturn[2] &= $aReturn[3]
$aReturn[3] = ''
EndIf
$sDrive = $aReturn[1]
$sDir = $aReturn[2]
$sParentDir = $aReturn[3]
$sFileName = $aReturn[4]
$sExtension = $aReturn[5]
Return $aReturn
EndFunc ;==>_PathSplitEx