Results 1 to 3 of 3

Thread: I have 10 files in a folder(say D:\). Out of which there

  1. #1
    Contributing Member
    Join Date
    Feb 2008
    Answers
    40

    I have 10 files in a folder(say D:\). Out of which there

    I have 10 files in a folder(say D:\). Out of which there
    are some .txt, .xls, .doc. I want to know how to get the
    count of each file using qtp?


  2. #2
    Junior Member
    Join Date
    Jan 2008
    Answers
    18

    Re: I have 10 files in a folder(say D:\). Out of which there

    Hi Suneetham,

    Please find the below code for the count particular file type.Insert the respective file extension & path.

    Dim fso, f,f1, fc, s

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder("C:\Documents and Settings\user\Desktop\New Folder")
    Set fc = f.Files
    For Each f1 In f.Files
    If LCase(Right(f1.name, 4)) = ".doc" Then
    b=f1.name
    msgbox b
    end if

    Thanks,
    MaluR

    next


  3. #3
    Expert Member
    Join Date
    Sep 2007
    Answers
    110

    Re: I have 10 files in a folder(say D:\). Out of which there

    Here you can find the count of the files....


    Set fso = createobject("scripting.filesystemobject")
    set fold = fso.getfolder("d:\testing files")
    set fc = fold.files

    word=0
    xls=0
    txt=0

    datatable.getsheet(1).addparameter"word",""
    datatable.getsheet(1).addparameter"excel",""
    datatable.getsheet(1).addparameter"text",""
    datatable.gdtsteet(1).addparameter"Total Files",""

    for each f in fold.files
    if lcase(right(f.name, 4)) = ".doc" then
    word=word+1
    end if
    if lcase(right(f.name,4))=".xls" then
    xls=xls+1
    end if
    if lcase(right(f.name,4))=".txt" then
    txt=txt+1
    end if
    next

    datatable(1,1)=word
    datatable(2,1)=xls
    datatable(3,1)=txt
    datatable(4,1)=fc.count
    run and see the runtime datatable.

    Last edited by rajaputra; 02-18-2008 at 11:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact