Wednesday, February 9, 2011

Script to Get Folder Properties

'Get Folder Properties
On Error Resume Next
dim objFSO
dim objFldr

'Specify folder you want information about
strFldr="c:\Neeraj"

set objFSO=CreateObject("Scripting.FileSystemObject")

'get a reference to the folder
set objFldr=objFSO.GetFolder(strFldr)

'list out properties
wscript.Echo "Folder Name:" & vbtab & objFldr.Name
wscript.Echo "Short Folder Name:" & vbtab & objFldr.ShortName
wscript.Echo "Folder Path:" & vbtab & objFldr.Path
wscript.Echo "Date Created:" & vbtab & objFldr.DateCreated
wscript.Echo "Date Last Accessed:" & vbtab & objFldr.DateLastAccessed
wscript.Echo "Date Last Modified:" & vbtab & objFldr.DateLastModified
wscript.Echo "Folder Size (bytes):" & vbtab & objFldr.Size
wscript.Echo "Folder Attributes:"

if objFldr.Attributes AND 0 then wscript.Echo " Normal"
if objFldr.Attributes AND 1 then wscript.Echo " Read-only"
if objFldr.Attributes AND 2 then wscript.Echo " Hidden"
if objFldr.Attributes AND 4 then wscript.Echo " System"
if objFldr.Attributes AND 8 then wscript.Echo " Volume"
if objFldr.Attributes AND 16 then wscript.Echo " Directory"
if objFldr.Attributes AND 32 then wscript.Echo " Archive Bit is set"
if objFldr.Attributes AND 1024 then wscript.Echo " Alias"
if objFldr.Attributes AND 2048 then wscript.Echo " Compressed"

set objFldr=Nothing
set objFSO=Nothing

No comments: