cancel
Showing results for 
Search instead for 
Did you mean: 

changing the filenames using unix script

Former Member
0 Kudos

Hi,

I have a scenario where I have to change the file names on the Receiver CC using a unix script and add date and timestamp to the file name

this is what I'll be writing to filename_01.xml I need to change that to newfilename_01_MMDDYYYY_HHMISS.xml

the 01 in the file name is the counter, so I might having more than one file where 01,02, etc will represent the counter on the filename.

Any help is really appreciated.

Thanks,

Joe.P

Accepted Solutions (0)

Answers (1)

Answers (1)

nisarkhan_n
Active Contributor
0 Kudos

you can try this

create the field called filename in target

use a costant and concat it with the out out of UDF( or some functon avaleiable counter) which will genereate numbers like 1,2,3,4,5,6 and send this filename_01 to the output field and use this in the variable substution to genreate the filename by the CC

if you dnt want to send this fieldin output file then specify that fieldname in CC length as 0

Former Member
0 Kudos

Hi,

Thanks for responding to my post, I'm using PI 7.0 the reason I did not go with counter in my message mapping since I'm not using FCC (file content conversion) I'm using file and using Add counter in the file processing parameter, and since I can either use a Add time stamp parameter or add counter in there, so I thought of using a unix script to rename the file names.

Thanks,

Joe.P

nisarkhan_n
Active Contributor
0 Kudos

but still any specific reason for using the unix script...you can do this evern with out FCC....help me inundrsanding your reply better (-:

Former Member
0 Kudos

the only reason I have to use unix script is I don't have other option of adding a counter and also adding a timestamp to the file at the same time. So I've decided to use the Add counter option within the file processing parameters and use a separate run command after the message processing and rename all the filenames to add the timestamp at the end. I hope I was able to explain clearly.

Thanks,

Joe.P

Former Member
0 Kudos

Jooe,

does your script able to change the name to your required name?

I think you can acheive this by using "run operating system command after processing" in the receiver File CC.

Babu SRi

nisarkhan_n
Active Contributor
0 Kudos

you use theoptio to adad the counter and add the timestamp in the mapping and concat with the filename and use it in variabel substution....

else

add counter to the filename in mapping using the UDF and select the time stamp in receiver adaapter.... evn when you processing XML you can achive this i belive....

Former Member
0 Kudos

but if I use the counter in the mapping using UDF I don't want the counter to be part of my out xml that's dumped into the file. in that case won't I need to use FCC and cut that variable out. I'm not using FCC since my output files are plain xml files.

thanks,

Joe.P