Hi

I have a String with a full Path of a file:

"C:\temp\temp2\temp3\MyFile.txt"

Now I don't want to work around and like to get follwing:

1. Filename (MyFile)
2. FileType (txt)

I know that I can beginn reading from the right of the string and exctract
what I need, but is there a simple function which do this for me?

Thanks alot!

Nijazi Halimaji

Re: Exctracting FileName and FileType out of a Full-Path by y

y
Thu Dec 02 08:10:12 CST 2004

"Don Hali" <spami@gmx.net> wrote in message news:u0z6SaH2EHA.2824@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I have a String with a full Path of a file:
>
> "C:\temp\temp2\temp3\MyFile.txt"
>
> Now I don't want to work around and like to get follwing:
>
> 1. Filename (MyFile)
> 2. FileType (txt)
>
> I know that I can beginn reading from the right of the string and exctract
> what I need, but is there a simple function which do this for me?
>

Use FileSystemObject like this.

wFile = "C:\temp\temp2\temp3\MyFile.txt"
With CreateObject("scripting.filesystemobject")
wscript.echo .GetBaseName(wFile)
wscript.echo .GetExtensionName(wFile)
End With

Y Sakuda from JPN



Re: Exctracting FileName and FileType out of a Full-Path by Torgeir

Torgeir
Thu Dec 02 08:09:07 CST 2004

Don Hali wrote:

> I have a String with a full Path of a file:
>
> "C:\temp\temp2\temp3\MyFile.txt"
>
> Now I don't want to work around and like to get follwing:
>
> 1. Filename (MyFile)
> 2. FileType (txt)
>
> I know that I can beginn reading from the right of the string and exctract
> what I need, but is there a simple function which do this for me?
Hi

'--------------------8<----------------------
sFile = "C:\temp\temp2\temp3\MyFile.txt"

Set oFSO = CreateObject("scripting.FileSystemObject")

WScript.Echo oFSO.GetBaseName(sFile)
WScript.Echo oFSO.GetExtensionName(sFile)
'--------------------8<----------------------

WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx