cancel
Showing results for 
Search instead for 
Did you mean: 

.bat file result not giving correctly in data services

venkataramana_paidi
Contributor
0 Kudos

Hi ,

I am using .bat file to count the number of files in the folder. I want to capture the value of the number of files.

I have written small .bat file as shown below

@echo off

setlocal enableextensions

CD %1

set cnt=0

for %%A in (*) do set /a cnt+=1

echo File count = %cnt%

endlocal

I have used this batch  file in the script as shown below.

$COUNT =exec('D:\\test.bat', 'D:\\docs',8);

print($COUNT);

In the above $COUNT is varchar(255).

actually i have only 11 file sin the docs folder . But it is giving the 442 files.

If I run the same batch file in the windows cmd command I am getting the correct result.

Please let me know what will be issues?

I am unable figure out the issues for weird result when I am using DS.

Please help me in this issue.

Thanks & Regards,

Ramana.

Accepted Solutions (1)

Accepted Solutions (1)

venkataramana_paidi
Contributor
0 Kudos

Hi,

While executing the batch file it is taking the Data services installation directory path as shown below.

14504    6420    PRINTFN    3/30/2015 9:40:10 AM    0: C:\Program Files (x86)\SAP BusinessObjects\Data Services\bin  File count = 442

I have changed the the batch file with two parameters. one for changing directory and another one for changing the folder.

Now my batch file looks like this.

@echo off

setlocal enableextensions

%1:

CD %2

echo %CD%

set cnt=0

for %%A in (*) do set /a cnt+=1

echo File count = %cnt%

endlocal

Then my script is like this .

$COUNT =exec('D:\\test.bat', ' D D:\\docs',8);

print($COUNT);

Now it is giving the expected result as shown below.

14700    13912    PRINTFN    3/30/2015 9:52:18 AM    0: D:\Docs  File count = 11

Thanks & Regards,

Ramana.

Answers (0)