You could use Perl to pipe in the date (either UNIX or windows) and
manipulate as you see fit.
Something like this could be used :
#!/usr/bin/perl
chop ($date = `date`);
@time = split (/\s+/,$date);
print "$time[0]-$time[2]-$time[1]-$time[5]";
-----Original Message-----
From: Dan Humiston
[mailto:oracledba-ezmlmshield-x90447483.[Email address protected]
Sent: 06 August 2007 15:32
To: LazyDBA Discussion
Subject: RE: rename a file using cmd by the system date
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
---------------------------------------------------------------------
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
--------------------------------------------------------------------------------------------------------------------
'This email and any files transmitted with it are confidential and intended solely for the use of the individual or
entity to whom they are addressed. If you have received this email in error please notify the system manager. Please
note that any views or opinions presented in this email are solely those of the author and do not necessarily
represent those of the Council. Finally, the recipient should check this email and any attachments for the presence
of viruses. The Council accepts no liability for any damage caused by any virus transmitted by this email.'
'Mae'r e-bost yma ag unrhyw ffeiliau trosglwyddwyd ynddi yn gyfrinachol ar gyfer defnydd yr unigolyn neu'r sefydliad
cyfeiriwyd ati yn unig. Os ydych wedi derbyn yr e-bost yma mewn camgymeriad rhowch wybod i reolwr eich system.
Nodwch taw unrhyw sylwadau neu farn soniwyd amdanynt yn yr e-bost yma ydi sylwadau a barn yr awdur ac nid yn
angenrheidiol yn cynrychioli rhai'r Cyngor. I orffen, dylid y person sy'n derbyn yr e-bost sicrhau nad oes firws
ynddi nac mewn unrhyw ddogfen sydd ynghlwm i'r e-bost. Nid yw'r Cyngor yn derbyn unrhyw gyfrifoldeb am unrhyw ddifrod
achoswyd gan unrhyw firws trosglwyddwyd gan yr e-bost yma.'
Oracle LazyDBA home page