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
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