来个纯手工的$FullPath = @ScriptFullPath
$FullPath = "\\192.168.0.108\tmp$\新建文件夹 (3)\Autoit_ACN\_____~~~T.au3"
$FullPath = "D:\192.168.0.108\tmp$\新建文件夹 (3)\Autoit_ACN\_____~~~T.au3"
ConsoleWrite("==============>"& $FullPath &@LF )
ConsoleWrite("==============>"& _fpGetName($FullPath, 1) &@LF )
ConsoleWrite("==============>"& _fpGetName($FullPath, 2) &@LF )
ConsoleWrite("==============>"& _fpGetName($FullPath, 3) &@LF )
ConsoleWrite("==============>"& _fpGetName($FullPath, 4) &@LF )
Func _fpGetName($string, $getname = 4) ; 1.drive / hostIP, 2.dir, 3.filename, 4.ext
If $getname = 1 Then
If StringInStr($string,":") = 2 Then
Return StringMid($string, 1, 1)
ElseIf StringInStr($string,"\") = 1 Then
Return StringMid($string, 1, StringInStr($string, "", 0, 1, 3) - 1 )
EndIf
ElseIf $getname = 2 Then
Return StringReplace( $String, StringMid( $string, StringInStr($string, "", 0, -1), StringLen($string) ) , "" )
ElseIf $getname = 3 Then
Return StringReplace( StringMid( $string, StringInStr($string, "", 0, -1)+1, StringLen($string) ) , StringRight( $string, StringLen($string) - StringLen(StringRegExpReplace($string, "\.\w+\Z", "", 1)) ), "" )
ElseIf $getname = 4 Then
Return StringRight( $string, StringLen($string) - StringLen(StringRegExpReplace($string, "\.\w+\Z", "", 1)) - 1 )
Else
Return ""
EndIf
EndFunc
|