PDA

View Full Version : VBScript - Read text from filename?


CobolExpert
04-15-05, 11:02
Hey all,
I have a file called 'Build 3.19.9.2600'. Nothing inside of it, it's just an automated file that is generated by a build process. I need to grab the last four digits of that filename and then put it into a string so that I can create a folder with it... Any ideas on how to do that? I tried a few things and haven't been able to get it to work so I'm not sure if it is possible.

I didn't find anything in my searches so hopefully this isn't a double post of something that was already answered.

Thanks!
JB

Kodo
04-15-05, 12:05
assuming you are familiar with the FileSystemObject.
Dim fso,Fname,BuildNo
Set fso = CreateObject("Scripting.FileSystemObject")
fname= FSO.GetFileName("pathhere")
BuildNo=right(fname,4)

CobolExpert
04-15-05, 12:10
Thanks Kodo. For some reason I was having problems with the last line. Brain Freeze I guess.

-JB

Kodo
04-15-05, 12:12
no prob...heck, I started to write it out and I'm so used to .NET now that I had a brain fart too :)