Skip to Content
avatar image
Former Member

BODS - Assigning file names to global variables using script

Hello All,

We have a requirement of reading the file names present on shared location in a BODS script, these files should be assigned to global variable FILE_NAME.

Our Job should check the file path, if file exists, should pick one file at a time, do the loading in respective targets and archive the file.

On the next run it should pick another file and take it forward(file name keep on changing every fortnight) and also we cannot assign the file names manually to the global variable.

I tried below command to get the list of all files present at the file path, however this is not helping me to assign it to the variable

print(exec('cmd','dir "[$File_Path]*.csv"',8));

I was thinking if there is any function by which we can get the latest modified timestamp of the file present on shared location.

Can anyone suggest me the solution on how we can get the file names assigned to global variable?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 18, 2016 at 08:14 AM

    Use

    print(word(exec('cmd','dir /b [$File_Path]*.zip',8),2));

    /b stands for bare format, returns file names only, no heading information nor summary.

    exec with 2nd parameter value 8 returns code first, then list of filenames, separated by blanks. The first file name is the 2nd word

    Make sure $File_Path ends with a backslash

    When you archive every processed file (move to another folder), you'll always process the next one automatically.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Dirk, it really worked.

      Now I am able to assign the files to the variable.

      Regards,

      Rajiv

  • Oct 18, 2016 at 09:50 AM
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2017 at 11:16 AM

    Hi experts, need your help. could you please solve this problem ASAP

    1) Once processed the .txt files , it should move to ARCHIVE folder. For this have seen more post's they were mentioned

    exec('cmd','move<source path><target path>,8) this is fine ,it's working but

    My requirement is

    2) Success-full files should move to one folder and failure files should move to another folder, as well as if file doesn't have even single record(ROW) ,this kind of files should move to another folder.

    Thanking you

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 22, 2017 at 11:17 AM

    Have been trying to post question's but doesn't take, that's why posted here.

    Add comment
    10|10000 characters needed characters exceeded