[AutoIt]Get File Extension, Filename, and Parent directory from Path 11-19-2011, 05:51 AM
#1
Code:
Func CompGetFileExt($Path,$Dot=True)
;by 1234hotmaster
If StringLen($Path) < 4 Then Return -1
$ret = StringSplit($Path,"\",2)
If IsArray($ret) Then
$ret = StringSplit($ret[UBound($ret)-1],".",2)
If IsArray($ret) Then
If $Dot Then
$Dot = "."
Else
$Dot = ""
EndIf
Return $Dot & $ret[UBound($ret)-1]
EndIf
EndIf
If @error Then Return -1
EndFuncCode:
Func CompGetFileName($Path)
;by 1234hotmaster
If StringLen($Path) < 4 Then Return -1
$ret = StringSplit($Path,"\",2)
If IsArray($ret) Then
Return $ret[UBound($ret)-1]
EndIf
If @error Then Return -1
EndFuncCode:
Func CompGetParentDir($Path,$EndSeparator=False)
;by 1234hotmaster
If StringLen($Path) < 4 Then Return -1
$ret = StringSplit($Path,"\",2)
If IsArray($ret) Then
Local $temp
For $i = 0 To UBound($ret)-2
$temp &= $ret[$i] & "\"
Next
If Not $EndSeparator Then $temp = StringTrimRight($temp,1)
$ret=Chr(0)
Return $temp
EndIf
If @error Then Return -1
EndFuncPierce the life fibers with your drill.




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)