Script Paradigm

パスからファイル名を抽出

ファイルパスからファイル名のみを抽出します。

Option Explicit
MsgBox fnGetFileNameByFilePath("C:\abc\test.txt")
Function fnGetFileNameByFilePath(ByVal strPath)
    Dim lIdx
    Dim strName
    
    lIdx = InStrRev(Replace(strPath,"/","\"), "\")
    If lIdx > 0 Then
        strName = Right(strPath, Len(strPath) - lIdx)
    Else
        strName = strPath
    End If
    
    fnGetFileNameByFilePath = strName
End Function
Copyright © 2006 Hikijishi All Rights Reserved.
[] [wsh][0.00206112861633301]