FsoModule.vbs
Option Explicit
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")
'Call TEST_20240812_124128
'// 親フォルダ(ディレクトリ)のパスを返す
Function GetDPath(ByVal full_path)
GetDPath = Fso.GetParentFolderName(full_path)
End Function
'// 親フォルダのフォルダ名(ディレクトリ名)を返す
Function GetDName(ByVal full_path)
With Fso
GetDName = .GetFolder(.GetParentFolderName(full_path)).Name
End With
End Function
'// ファイル名を返す
Function GetFName(full_path)
GetFName = Fso.GetFileName(full_path)
End Function
'// 拡張子を除いたファイル名(Base名)を返す
Function GetBName(ByVal full_path)
GetBName = Fso.GetBaseName(full_path)
End Function
'// 拡張子を返す ※ u_case が False の場合は小文字にして返す
Function GetExt(ByVal full_path, ByVal u_case)
Dim ext
ext = Fso.GetExtensionName(full_path)
If Not u_case Then ext = LCase(ext)
GetExt = ext
End Function
'// 配列の要素をすべてつなげたパスを返す
Function GetBuildPath(param_ary)
Dim i
Dim pathStr
With Fso
For i = LBound(param_ary) To UBound(param_ary)
pathStr = .BuildPath(pathStr, param_ary(i))
Next
End With
GetBuildPath = pathStr
End Function
Sub TEST_20240812_124128()
Dim adinPath, appdata, msg
appdata = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%APPDATA%")
adinPath = GetBuildPath(Array(appdata, "Microsoft", "AddIns", "ADIN.xlam"))
msg = adinPath
msg = msg & vbCrLf & GetDPath(adinPath)
msg = msg & vbCrLf & GetDName(adinPath)
msg = msg & vbCrLf & GetFName(adinPath)
msg = msg & vbCrLf & GetBName(adinPath)
msg = msg & vbCrLf & GetExt(adinPath, False)
MsgBox msg
End Sub