detecting a word in a file name 
Author Message
 detecting a word in a file name

Can I detect a word in a file name with VBS?
Example : I want to detect the word "jedi" in the file name "return of the
jedi.doc", or "jedi hard.mp3".
I tried to look for the strings functions in the help, but it seems very
complicated.
If anyone could get me started it would be great :o]
Thanks

--
bizous +++++ gz



Fri, 17 Dec 2004 10:07:44 GMT  
 detecting a word in a file name
you use Instr() - and you use FileSystemObject to obtain the name in the
first place. all is explained in the docs.

function String.prototype.r(){// Javascript rot13 en/decipherment. run
me for Atrax's signature
        var a='nopqrstuvwxyz';var b='abcdefghijklm';var j='/:.'+a+b;var
k='/:.'+b+a;var l='';
        for(var
x=0;x<this.length;x++){l+=k.charAt(j.indexOf(this.charAt(x)));}return l;

Quote:
}       alert("uggc://jjj.ernqgurshpxvatznahny.pb.hx/".r()); // Atrax, MVP

2002.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 17 Dec 2004 13:24:13 GMT  
 detecting a word in a file name
Hi.

Here's a script that search thru a folder and tells if a jedi is found:

______________________________
'Create a filesystemobject and a folderobject
Set fso = CreateObject("scripting.filesystemobject")
Set myFold = fso.getfolder("f:\dokumenter")

'each file in the folder is checked for jedi
For each fil in myFold.files

myVar = LCase(fil.name)

if instr(myVar, "jedi") Then msgbox myVar,,"Hit"

Next

wscript.echo "finished"

Set fso = nothing
Set myfold = nothing
_________________________________

regards
Kaj



Quote:
> Can I detect a word in a file name with VBS?
> Example : I want to detect the word "jedi" in the file name "return of the
> jedi.doc", or "jedi hard.mp3".
> I tried to look for the strings functions in the help, but it seems very
> complicated.
> If anyone could get me started it would be great :o]
> Thanks

> --
> bizous +++++ gz



Sat, 18 Dec 2004 00:17:53 GMT  
 detecting a word in a file name
Thank you both!! You're da true Jedis! :)

--
bizous +++++ gz



Sat, 18 Dec 2004 11:53:56 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Word VBA to Save File Name from MergeField

2. Converting Long File Names to Short File Names

3. Getting short file name from long file name:

4. Converting Long File Names to Short File Names

5. Converting Short File Names to Long File Names

6. best way to detect if a word document is currently open

7. Want to convert PS files to Word/Word Perfect

8. file named randomly instead of user name

9. File name or class name not found during Automation operation

10. Open word-file in MS Word from link in IE

11. WshMapNetworkDrive with a two word share name

12. SAving a MS Word file to a PDF file and a text file

 

 
Powered by phpBB® Forum Software