need to include sysdate into the file name
Moderators: chulett, rschirm, roy
need to include sysdate into the file name
Actually i am ftping the file from the upstreams to ETL server, in the ETL server i need to keep the filename as TCyyyymmdd.txt where YYYYMMDD is the current date.
Can anyone assist me in this.
Re: need to include sysdate into the file name
Jagan617 wrote:
Actually i am ftping the file from the upstreams to ETL server, in the ETL server i need to keep the filename as TCyyyymmdd.txt where YYYYMMDD is the current date.
Can anyone assist me in this.
After FTP,you can rename as
mv filename filename_`date '%Y%m%d`
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That is trickier to do on a Windows operating system. You could use a routine from a Routine activity. The following code is generic - it will work on either UNIX or Windows. Error handling has been omitted for clarity.
Code: Select all
FUNCTION AddDateToFileName(FileName)
* Add yyyymmdd between base name and suffix.
* FileName is the pathname of the file to be changed.
* Generates and executes appropriate rename command.
Ans = @NULL
Elements = DCount(FileName, ".")
BaseName = Field(FileName, ".", 1, Elements - 1)
Suffix = Field(FileName, ".", Elements, 1)
Call !GET.PATHNAME(FileName, DirPath, EntryName, StatusCode)
NewFileName = EntryName : Oconv(@DATE,"DYMD[4,2,2]":@VM:"MCN") : "." : Suffix
If System(91)
Then
Shell = "DOS"
Command = "REN " : FileName : " " : NewFileName
End
Else
Shell = "UNIX"
Command = "mv " : FileName : " " : NewFileName
End
Call DSExecute(Shell, Command, Output, ExitStatus)
Ans = ExitStatus
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.