Filename wildcards as arguments to script 
Author Message
 Filename wildcards as arguments to script

Greetings...

Anyone know if its possible/howto use filename-wildcards when calling my
script ?

To be more specific - I want to execute the script as "myVBScript
c:\temp\*.*" - and then do something with the files/dirs afterwards (in
fact, calling another program with a oshell.Run and then pass the argument
on to this) - this could be hundreds of files and directories, so i dont
just want to add more arguments.

The argument part of my script looks like this :

If WScript.Arguments.count = 0 Then
 Call HowTo
Else
   Set oShell = CreateObject("Scripting.FileSystemObject")
   If (oShell.FileExists(WScript.Arguments(0))) Then Filename =
WScript.Arguments(0)
End If

Any hints/suggestions welcome, perhaps it's just me who's thinking in wrong
terms :-)



Thu, 03 Feb 2005 07:16:26 GMT  
 Filename wildcards as arguments to script
You could

  wshShell.Exec("%comspec% /c dir/b " + WScript.Arguments(0))

and loop through the output.

--
A penny will hide the biggest star in the universe if you hold it close
enough to your eye. -Samuel Grafton

=-=-=
Steve
-=-=-


Quote:

> Greetings...

> Anyone know if its possible/howto use filename-wildcards when calling my
> script ?

> To be more specific - I want to execute the script as "myVBScript
> c:\temp\*.*" - and then do something with the files/dirs afterwards (in
> fact, calling another program with a oshell.Run and then pass the argument
> on to this) - this could be hundreds of files and directories, so i dont
> just want to add more arguments.

> The argument part of my script looks like this :

> If WScript.Arguments.count = 0 Then
>  Call HowTo
> Else
>    Set oShell = CreateObject("Scripting.FileSystemObject")
>    If (oShell.FileExists(WScript.Arguments(0))) Then Filename =
> WScript.Arguments(0)
> End If

> Any hints/suggestions welcome, perhaps it's just me who's thinking in
wrong
> terms :-)



Thu, 03 Feb 2005 19:02:29 GMT  
 Filename wildcards as arguments to script

Quote:

> Anyone know if its possible/howto use filename-wildcards when calling my
> script ?

> To be more specific - I want to execute the script as "myVBScript
> c:\temp\*.*" - and then do something with the files/dirs afterwards (in
> fact, calling another program with a oshell.Run and then pass the argument
> on to this) - this could be hundreds of files and directories, so i dont
> just want to add more arguments.

Hi


Subject: Check if file(s) exists - using wildcards
Newsgroups: microsoft.public.scripting.wsh
Date: 2000/05/25
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=e9b079...

--
torgeir



Fri, 04 Feb 2005 04:53:06 GMT  
 Filename wildcards as arguments to script
You can not evaluate a wildcard statement for existence. However you can
check the base folder.
This sample will do:
====================================
Dim fso, FilesPath, BaseFolder, OK
If WScript.Arguments.count = 0 Then  Call HowTo(1)
Set fso = CreateObject("Scripting.FileSystemObject")
FilesPath = WScript.Arguments(0)
Select Case Instr(FilesPath, "*")
    Case 0 : If fso.FileExists(FilesPath) then OK = True
    Case Else
        BaseFolder = fso.GetParentFolderName(FilesPath)
        If fso.FolderExists(BaseFolder) Then OK = True
End select
If OK then Wscript.Echo FilesPath Else: Call HowTo(2)

'..
'..

Sub HowTo (error)
Select Case error
    Case 1
Wscript.Echo "Argument is missing. Error: " & error
    Case 2
Wscript.Echo "Path to the File(s) is Invalid. Error: " & error
'..
'..
End Select
Wscript.Echo "Syntax: vbscript.vbs [valid_path]"
Wscript.Quit error
End Sub
=====================================

-regards-

Gurgen Alaverdian
http://www.gurgensvbstuff.com

Quote:

> Greetings...

> Anyone know if its possible/howto use filename-wildcards when calling my
> script ?

> To be more specific - I want to execute the script as "myVBScript
> c:\temp\*.*" - and then do something with the files/dirs afterwards (in
> fact, calling another program with a oshell.Run and then pass the argument
> on to this) - this could be hundreds of files and directories, so i dont
> just want to add more arguments.

> The argument part of my script looks like this :

> If WScript.Arguments.count = 0 Then
>  Call HowTo
> Else
>    Set oShell = CreateObject("Scripting.FileSystemObject")
>    If (oShell.FileExists(WScript.Arguments(0))) Then Filename =
> WScript.Arguments(0)
> End If

> Any hints/suggestions welcome, perhaps it's just me who's thinking in
wrong
> terms :-)



Fri, 04 Feb 2005 05:18:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Arguments pass short 8.3 filename, how pass LFN?

2. Full Filename argument

3. Full Filename argument

4. DOS wildcard, *, not valid with .FileName?

5. Using WildCard (*) with .FileSearch.Filename in Access97 VBA with Windows 2000

6. Filling FileOpenDialog with filenames containing wildcards

7. Passing File1.filename as argument

8. How do I use wildcard for VB Scripts?

9. Using wildcard in scripting regestry entries

10. Setting printers via wildcard in .vbs script

11. WSH script arguments as script

12. Running a script with arguments.

 

 
Powered by phpBB® Forum Software