Saturday, May 17, 2014

QTP code to find the files name and subfolders of a folder

'to find the files name and subfolders of a folder
      Option explicit
      Dim ohdd, ofo, osfs, n, s, osf, ofs, of, na, ns
'goto hdd
      Set ohdd=createobject("scripting.filesystemobject")
'goto folder
      Set ofo=ohdd.getfolder("F:\QTP")
'goto subfolder
      Set osfs=ofo.subfolders
      Set ofs=ofo.Files
For each of in ofs
na=of.name
ns=of.size
ns=ns/1024
print(na&"   size   =  "&ns&"KB")
Next
print ("------folders-----")
'get all folders names and size individually
For each osf in osfs
   n=osf.name
   s=osf.size
   s=s/1024^2
   print(n&" Size is ="&s&"MB")
Next
'destroy objects
Set osf=nothing
Set osfs=nothing
Set ohdd=nothing

No comments:

Post a Comment