cancel
Showing results for 
Search instead for 
Did you mean: 

rename file with prefix in sap bods

former_member241220
Participant
0 Kudos

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,
Murali

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

Hello!

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


former_member187605
Active Contributor
0 Kudos

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 (help.sap.com) for details.

Former Member
0 Kudos

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