Extracting drive, path, filebasename WITH string functions and NOT system function ???

  • Thread starter Thread starter Thomas Lebrecht
  • Start date Start date
T

Thomas Lebrecht

Recently I asked here for functions to extract the individual
parts (drive, path, filebase and extension) from a string like:

myfile="D:\aaa\bbb\ccc\ddd.txt"

I was told to use built-in functions like:

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strFile)
Set objFolder = objFile.ParentFolder
Wscript.Echo "Filename : " & objFile.Name
Wscript.Echo "Path : " & objFile.ParentFolder

But the big disadvantage here is that the file MUST exist.

But what if the filenamestring is passed as parameter and tells which log file should be created
(in the future). At the moment of processing the logfile does not exist yet.

So all the built-in funtion don't work and I get an error.

I must use some string manipulation functions like:

Wscript.Echo "Path : " & Left(strFile, InstrRev(strFile, "\"))

But how can I extract similarly filebase name ("ddd"), extension ("txt"),
filename ("ddd.txt") and drive ("D:") with string search and copy functions?

Thomas
 
Thomas said:
Recently I asked here for functions to extract the individual
parts (drive, path, filebase and extension) from a string like:
<snip vbscript>

Wrong newsgroup again. But I see you have the followup set to the correct
newsgroup.

Andrew
 
Thomas Lebrecht said:
Recently I asked here for functions to extract the individual
parts (drive, path, filebase and extension) from a string like:

Recently I told you, NOT to post vbscript questions to the VB.net group. I
tell you again, now.


Armin
 
Recently I told you [Thomas Lebrecht], NOT to post vbscript
questions to the VB.net group. I tell you again, now.

Why not? It's got "vb" in its name, so it's fair game ;-) At least that's
what the various dotnet evangelists such as the idiot McCarthy tell us when
we ask people not to post vb.net questions to the class Visual Basic group!

Mike
 
Back
Top