Rehab,
In Unix/Linux, you can use the date command:
export dt=`date +"%d%m%Y"`
mv file.csv $dt.csv
Note that the tick marks in the export statement are the ones on the
tilde (~) key, not on quotes (").
Windows/DOS batch becomes more complicated. I have a script that pulls
date out and allows you to reformat, but it may need some tweaking,
depending on your version of Windows/DOS.
FOR /F "TOKENS=1* DELIMS= " %%A IN ('ECHO %DATE%') DO SET
CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('ECHO %DATE%') DO
SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('ECHO %CDATE%') DO
SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('ECHO %CDATE%') DO SET
yyyy=%%B
set outfile=%dd%%mm%%yyyy%.csv
move file.csv %outfile%
On a side note, I'd recommend using year, then month, then date, as
it'll keep your backups better organized in a directory listing.
Hope this helps!
Dan Humiston
-----Original Message-----
From: Rehab Raafat
[mailto:oracledba-ezmlmshield-x75579934.[Email address protected]
Sent: Monday, August 06, 2007 08:46
To: LazyDBA Discussion
Subject: rename a file using cmd by the system date
Hi all,
Does any body can help?
I already have a batch file that runs in a schedule & loads the data
file file1.csv, and I need to make rename for the data file after
loading it to the system date
For example:
The data file is file1.csv(which is created daily by a schedule)
& I want to rename it by sysdate.csv --> ddMMyyyy--> 06082007.csv
Sure tomorrow will differ, file.csv will be-->07082007.csv
So I need something like rename but in the formate of ddmmyyyy(sysdate)
Thanks a lot & best regards for all
Rehab :-)
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
Oracle LazyDBA home page