Skip to Content

How to get the count of files in a directory in BODS

Hi Experts,

I have a scenario, we need to get the count of files in a directory and load it into a variable,Please suggest me is there any in-built function available in BODS or any work around for that

Thanks in Advance.........!

Best Regards,

Sudheer.M

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 05, 2017 at 01:59 PM

    Create a batch job in data services designer and declare the following global variables: $file_names - varchar(1000), $FILE_COUNT - int, . Create a script as follows:

    wait_for_file('C:\Program Files (x86)\SAP BusinessObjects\Data Services\dsdata\*.txt', 1, 1, -1,$file_names, $FILE_COUNT,',');

    print('Number of file found = ' || $FILE_COUNT);

    print('File names = ' || $file_names);

    The script shows an example of where to look for the files. You can change it according to your system. In this case it looks for all text files in the folder: C:\Program Files (x86)\SAP BusinessObjects\Data Services\dsdata. You can mention your path. file names will be printed with comma separated.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 06, 2017 at 05:34 AM

    Hi Jayasree,

    Thanks for your quick response, We already have some files in the folder so we need to get the count of the files and names of the files, So that we will process those files accordingly.Please give me is there any other way to get the information for already exist files.

    Best Regards,

    Sudheer.M

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 06, 2017 at 12:46 PM

    Hi Jayasree,

    Thanks, Its working i can able to get the count by using wait_for_file function as suggested by you. It satisfies my requirement.

    Best Regards,

    Sudheer.M

    Add comment
    10|10000 characters needed characters exceeded