How can I get the filename and drop everything after the dot.

For example,

Execute test.vbs that calls this statement inside of script:

test=Wscript.ScriptName

Output is : test.vbs


Now all I want is the filename test. How can I always drop the .vbs in this
case.

Re: filename by Torgeir

Torgeir
Thu Jun 23 08:07:26 CDT 2005

Big D wrote:

> How can I get the filename and drop everything after the dot.
>
> For example,
>
> Execute test.vbs that calls this statement inside of script:
>
> test=Wscript.ScriptName
>
> Output is : test.vbs
>
> Now all I want is the filename test. How can I always drop the
> .vbs in this case.
Hi,

WScript.Echo Split(WScript.ScriptName, ".")(0)

or

Set oFSO = CreateObject("Scripting.FileSystemObject")
WScript.Echo oFSO.GetBaseName(WScript.ScriptName)



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

Re: filename by TEC

TEC
Fri Jun 24 15:30:26 CDT 2005

You should always use the second method as the first will only return text
before the first period. if you use multiple dots in your file name ie
script.today.vbs you will only return script
The second method returns the whole file name minus the extension, ie
script.today

"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:%23leT8T$dFHA.3352@TK2MSFTNGP09.phx.gbl...
> Big D wrote:
>
>> How can I get the filename and drop everything after the dot.
>>
>> For example,
>>
>> Execute test.vbs that calls this statement inside of script:
>>
>> test=Wscript.ScriptName
>>
>> Output is : test.vbs
>>
>> Now all I want is the filename test. How can I always drop the
>> .vbs in this case.
> Hi,
>
> WScript.Echo Split(WScript.ScriptName, ".")(0)
>
> or
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> WScript.Echo oFSO.GetBaseName(WScript.ScriptName)
>
>
>
> --
> 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