cancel
Showing results for 
Search instead for 
Did you mean: 

BODS - Assigning file names to global variables using script

0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

former_member187605
Active Contributor
0 Kudos

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.

0 Kudos

Thanks Dirk, it really worked.

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

Regards,

Rajiv

former_member749958
Discoverer
0 Kudos

Hi Dirk,

I am using same but not getting the file name from a directory. instead it is printing something 'The'.

$G_File_Name =(word(exec('cmd','dir /b [$Sales_Load_Direcotry]*.txt',8),2));

print($G_File_Name);

$$Sales_Load_Direcotry= C:\Training Files\New folder\

$G_File_Name is a global variable here

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member198401
Active Contributor
0 Kudos