Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
238 views

How To Use Windows Commands in BODS

This document provides examples of using Windows commands (CMD) in BODS to perform common file operations like generating headers, redirecting output, merging files, removing blank lines, counting records, removing special characters, generating keys for flat files, counting files in a folder, printing file names, and picking the latest file. Commands demonstrated include ECHO, TYPE, COPY, FINDSTR, FIND, DIR, and REGEX_REPLACE.

Uploaded by

yella reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views

How To Use Windows Commands in BODS

This document provides examples of using Windows commands (CMD) in BODS to perform common file operations like generating headers, redirecting output, merging files, removing blank lines, counting records, removing special characters, generating keys for flat files, counting files in a folder, printing file names, and picking the latest file. Commands demonstrated include ECHO, TYPE, COPY, FINDSTR, FIND, DIR, and REGEX_REPLACE.

Uploaded by

yella reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

How to use windows commands in BODS

1. How to generate UTF8 or any word or value as header in a file by using


Echo function.

Source:

Target:

A. To achieve the above requirement use the below script.

EXEC ( 'CMD','@ECHO UTF8> filetest.csv');

2. How to redirect the output file content to another new file.

A. By using Type function we can redirect the content of the file and it will create a new file
with the copied data.

Print ( exec( 'CMD', 'TYPE \\\filepath\ Multiple_output.csv > \\\filepath\filetest.csv'));

3. How to merge the data from multiple files to one file even if the
structure is not the same.
A. Use the copy command and /b parameter to merge the files.

Print ( exec ( 'CMD', 'COPY /b \\\filepath\Multiple_output.csv + \\\filepath\filetest.csv


>\\\filepath\filetest3.csv'));

4. Output can be appended to an existing file.

A. By using Type function we can append the data to an existing file.

Print (exec (‘CMD’, 'TYPE Output_file.csv > > Existing file’));

5. How to remove the blank lines (Rows) in a source file. If any blank lines
exist in our source file, BODS will throw error as below.

A. By using findstr function and /v parameter we can achieve this.

Print ( exec( 'CMD', 'findstr /v "^$" "\\\filepath\BLANKCSV.CSV" >


filepath\Blank2.csv'));

6. How get the record count from the file.

A. By using find command and /v /c parameters will get the record count.

word_ext( exec( 'cmd','find /v /c "|" [$G_JOB_SERVER_PATH]\[$G_FILENAME] '),-1,':');

OR

print( exec( 'cmd' , 'findstr /R /N "^" Filename.txt| find /c "file delimiter"'));

7. How to remove special characters in given string.

A. print( regex_replace( 'Ac@,*^&cou+-nti¬ng','\\[@,*,^,&,¬,-,+\\]',''));

For some values we need to use escape characters \-\

8. Using key generation function for flat file.


key_generation(FF_KEY_TARGET."\\\key_target.txt",'key',1)
Here FF_KEY_TARGET means Target file format name
key_target.txt is target file.

9. Count the number of files in a folder.

print( exec('cmd','dir \filepath\*.txt| find "File(s)"'));


(or )
print( exec('cmd','dir filepath\*.txt /b | find /v /c "\"'));

10.Print all the file names from a single folder.

exec ( 'cmd','dir/b \\\filepath\filename*.txt' );

11.Pick the latest filename from group of files in a folder

print( word_ext( exec( 'cmd','dir/b /o-d \\\ filepath\*.xml ' ),1,' '));

12. Below is for count of directories in a folder


print( exec('cmd','dir /b /o:-d /a:d \\\filepath | find /c /v ":" '));

13. Below is for count of files in a folder


print( exec('cmd','dir /b /o:-d /a-d \\\filepath\*.txt | find /c /v ":" '));

You might also like