Algorithms, Blockchain and Cloud

Parse a Filename using Scripting.FileSystemObject


Scripting.FileSystemObject is a powerful utility, that is often used in Scripting languages.

In [here], the Scripting.FileSystemObject is used to verify if a folder exists. It can be also used to parse a filename. For example,

' Parse a Path Name
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Go\Robots.txt")

WScript.Echo "Absolute path: " & objFSO.GetAbsolutePathName(objFile)
WScript.Echo "Parent folder: " & objFSO.GetParentFolderName(objFile) 
WScript.Echo "File name: " & objFSO.GetFileName(objFile)
WScript.Echo "Base name: " & objFSO.GetBaseName(objFile)
WScript.Echo "Extension name: " & objFSO.GetExtensionName(objFile)

will produce the following if the file Robots.txt exists, otherwise ‘File Not Found’ Exception will be thrown out.

Absolute path: C:\Go\robots.txt
Parent folder: C:\Go
File name: robots.txt
Base name: robots
Extension name: txt

–EOF (The Ultimate Computing & Technology Blog) —

194 words
Last Post: Using Minimum Spanning Tree to Solve the Graph-releated Problem: Learning Languages
Next Post: Compute e Again

The Permanent URL is: Parse a Filename using Scripting.FileSystemObject (AMP Version)

Exit mobile version