Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


using fileexists method with wildcard

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2422
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> using fileexists method with wildcard
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 using fileexists method with wildcard - 3/22/2005 1:06:42 AM   
  netherxx

 

Posts: 8
Score: 0
Joined: 3/22/2005
From:
Status: offline
Hi there,

first of all, sorry for my crappy english.

I relatively new with vbscript/wsh. I am creating a script that will automatically move a series of tars to a directory, that is named to the date that the script has been run.

That part does work.
However, i want the script to check if there are *.index files in the directory, and if they are there, the script should end.
Now, i have got the script so far that it will check for a specific file, but not for a bunch of files i have specified with a wild card in the fileexists method. Can you help me?

Thanks in advance

Kind regards,

Rolf

Dim wshnetwork, fso, lfile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set wshnetwork = WScript.CreateObject("wscript.network")
Set fso = CreateObject("scripting.filesystemobject")
Set Lfile = fso.OpenTextFile("c:\call-it.log", ForWriting, True)

On Error Resume Next

Lfile.WriteLine Now & "-> verwijderen van netwerkmapping K:"
wshnetwork.RemoveNetworkDrive "K:"

Lfile.WriteLine Now & "-> maken van netwerkmapping K:"
wshnetwork.MapNetworkDrive "K:", "\\deltamdb02\vpcprod\call_it"

lfile.WriteLine Now & "-> checken of er nog indexen bestaan in de map verwerken"
If (fso.FileExists("k:\verwerken\*.index"))=false Then
lfile.WriteLine Now & "-> error! er bestaan nog indexen in de verwerken map. Bestanden worden niet verplaatst"
WScript.Quit
Else
lfile.WriteLine Now & "-> er bestaan geen indexen. Indexen zijn verwerkt"
End if


Lfile.WriteLine Now & "-> maken van backupmap op \\deltamdb02\vpcprod\call_it\ready\"
fso.CreateFolder ("K:\ready\"&date)

Lfile.WriteLine Now & "-> verplaatsen van alle tars"
fso.MoveFile "k:\verwerken\*.tar", "K:\ready\"&date

lfile.WriteLine Now & "-> verwijderen van netwerkmapping K:"
wshnetwork.RemoveNetworkDrive "K:"

lfile.Close
 
 
Post #: 1
 
 Re: using fileexists method with wildcard - 3/22/2005 1:20:43 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
One possibility is to use the file collection and check each file extension. This would be fairly quick if there are not many files in the folder. As you get up to the high hundreds this might take a while, but should be viable for less.
There is probably a better way, but here is an example.


      

(in reply to netherxx)
 
 
Post #: 2
 
 Re: using fileexists method with wildcard - 3/22/2005 1:52:01 AM   
  netherxx

 

Posts: 8
Score: 0
Joined: 3/22/2005
From:
Status: offline
Mike,

thanks for the solution. Works like sunshine.

Rolf

(in reply to netherxx)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> using fileexists method with wildcard Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts