Reputation: 12566
I'm working with a SVN post-commit hook, and need to extract the last piece of info after a \
in a path.
Basically I need to get testName
from:
C:\Program Files (x86)\WANDisco\uberSVN\testName
Where that string is in a variable, repoName
.
Completely wrong language, but in PHP, i'd explode()
the string at the \
, then get the last item in the array. I hope this is easy, but VBScript is completely foreign to me.
Upvotes: 1
Views: 1627
Reputation: 802
Are you trying to get a file name from a path? If so the proper way to do this in VBScript is with a FileSystemObject like so:
dim filesys, filename, path
Set filesys = CreateObject("Scripting.FileSystemObject")
path = filesys.GetAbsolutePathName("c:\somefile.txt")
getname = filesys.GetFileName(path)
If you really just want to split a string, use: VBScript Split function
Upvotes: 2
Reputation: 7641
Try using the FileSystemObject:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Program Files (x86)\WANDisco\uberSVN\testName")
Set repoName = objFSO.GetFileName(objFile)
Upvotes: 1