JSI Tip 10487. How can a Vbscript determine the drive/folder path of a Fully Qualified File Name argument?


The following scriptlet demonstrates how you can extract the drive/folder path of a Fully Qualified File Name argument:

Dim objArgs
Set objArgs = Wscript.Arguments
if objArgs.Count  1 then 
 Wscript.Echo  "FQFN is required"
 WScript.Quit (1)
End If
FQFN = objArgs(0)
fName = mid(FQFN, instrrev(FQFN, "\") + 1) ' Determine file name 
pName = Mid(FQFN, 1, (Len(FQFN) - Len(fName) - 1)) ' Determine number of characters in drive/folder path
wscript.echo pName



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish