Skip to Content
0

BODS - Assigning file names to global variables using script

Oct 17, 2016 at 11:22 PM

601

avatar image

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Dirk Venken
Oct 18, 2016 at 08:14 AM
0

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Dirk, it really worked.

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

Regards,

Rajiv

0
Arun Sasi Oct 18, 2016 at 09:50 AM
0
Share
10 |10000 characters needed characters left characters exceeded
dilip kumar May 22, 2017 at 11:16 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
dilip kumar May 22, 2017 at 11:17 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded