Saturday 29 August 2015

extract file extension using vbs 'GetExtensionName' method..

pat="C:\Documents and Settings\vgopi\Desktop\Perso\"
Set fs = CreateObject("Scripting.FileSystemObject") 
Set fold= fs.GetFolder(pat)
Set fil=fold.Files
For Each f In fil
    if fs.GetExtensionName(f.Path)="txt" Then    
        MsgBox     "File Name: '"& f.Name & "' and its extension:- "& fs.GetExtensionName(f.Path) 
    End If
    
NExt
Set fs = Nothing

No comments:

Post a Comment