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

  • Thread starter Thomas Lebrecht
  • 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
 
A

Andrew Morton

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
 
A

Armin Zingler

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
 
M

Michael Williams

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top