Skip to Content

rename file with prefix in sap bods

Jun 10, 2017 at 08:40 AM


avatar image
Former Member

Hi Experts,

I have fail name "Murali06062017" . I need to rename file like "Ready_Murali06062017" in bods using rename DOS commands.

I have multiple files in a path.
1. Murali06062017
2. Krishna06062017 in D:\Temp folder

I need to rename files in same path D:\Temp Folder
1. Ready_Murali06062017
2. Ready_Krishna06062017

For this I tried this way. But it was not worked

exe('cmd','rename D:\Temp\*.txt Ready_*.txt')

Please get me help on this. I google it but could not able to find proper solution.

Thanks and Regards,

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

1 Answer

avatar image
Former Member Jun 13, 2017 at 01:40 PM


I have something similar developed. I hope it be usefull, and sorry for my English.

Let me Know if it helps you.!!!!!!!!!!!!!!!!!!

I used a .bat and then I execute from BODS. Like this:

The bat move and rename a file depend on the variables send it trhough BODS. I control the rename if the file was success or failed, so I sent the prefix.

and then in BODS, Look like:

A variable has the control, if variable = 0 that error. I move the file to a carpet called Error.

If variable <> 0 that success. I move the file to a carpet called Exito (success). Both case I rename the name of the file.

I leave the code

@echo off
rem echo Probando
rem set ruta1=E:\CargasDs\
rem set ruta2=E:\CargasDs\Exito\
rem set archivo=Libro1.xlsx

 set ruta1=%1
 set ruta2=%2
 set archivo=%3
 set renombre=%4

rem move C:\carpeta1\DSConfig.txt C:\carpeta2
rem move C:\carpeta1\DSConfig.txt %ruta2%
echo %ruta1%%archivo% %ruta2%
move %ruta1%%archivo% %ruta2%

ren %ruta2%%archivo% %renombre%%archivo%

rem pause

bat.png (13.1 kB)
bods.png (21.8 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Why reinvent the wheel???

There's a DS built-in function called file_move that exactly does what you need. Check the SAP Data Services Refeence Guide ( for details.

Former Member

Ok Dirk. Thanks for your correction. I´ll try.