Set a generic name to some specific files VBS...

May 14, 2013 at 06:00:46
Specs: Windows 7
By the use of a generic name, I need to check if some specific files exist before deleting them. For example if I have three files named: info-American, info-French, info-Russian;...
First off, I want to test if one exist and delete it if it's the case.

Here's what I have writen, but it doesn't work!

Set obj = CreateObject("Scripting.FileSystemObject")
If obj.FileExists("info*") Then
obj.deleteFile "info*"
End If

Please, any help!

See More: Set a generic name to some specific files VBS...

Report •

May 14, 2013 at 07:16:12
Not obvious where you're headed.

But it may be as simple as:

del info*

If it doesn't exist, it won't be deleted. [surprise]

M2 Golden-Triangle

Report •

May 14, 2013 at 08:47:50
Thanks Mechanics, but I am in VBS, not in Batch.
A way to do that is to create a directory and put these files into this one. Then delete it.
But Let me ask if it is not possible to mark these files with a generic file name to kill them then?
Thank you

Report •

May 14, 2013 at 21:21:13
You could always cheat and do this:
set wshell=createobject("")
'then:"cmd /c del info-*.")
set z=wshell.exec("cmd /c del info-*.")

Report •

Related Solutions

May 15, 2013 at 06:24:40
FileExists does not take wildcards, but DeleteFile does. If you're worried about DeleteFile throwing an error if it doesn't find anything to delete, just tell VBS to ignore it.
On Error Resume Next
  obj.deleteFile "info*"
On Error GoTo 0

How To Ask Questions The Smart Way

Report •

Ask Question