Avatar of LindaC
LindaCFlag for Puerto Rico

asked on 

Adding a date to a file name in a bat file so that every day will be a different name

I want to execute an oracle export but the name of the dump file I want to add the day-month-and year so that each day the dump file be created with a different name.
Don't worry about disk space because I have another script which removes dump files older than 4 days:
This is the script that Iám using:

set ORACLE_SID=OEM10G
set a=exp_oem10g_%DATE:.=%
set b=oem10g_%DATE:.=%
E:\oracle\product\10.2.0\db_1\BIN\expdp.exe backup_user/backup_user dumpfile=dpump_dir1:%b%.dmp filesize=0 content=all logfile=dpump_log1:%a%.log full=y
date /t >> E:\oracle\Dba\logs\%a%.log
c:
cd \progra~1\tivoli\tsm\baclient
dsmc incremental E:\oracle\Dba\exports\%b%.dmp >> E:\oracle\Dba\logs\%a%.log
date /t >> E:\oracle\Dba\logs\%a%.log
exit

The logfile it is written as exp_oem10g_Tue (type File) and the dump file is not written because it is like this:

What I want is that the dumpfile it is written as oem10g_2-27-07.dmp  and the logfile as exp_oem10g_2-27-0.log --------------> The date of today

Incremental backup of volume 'E:\oracle\Dba\exports\oem10g_Tue'

Incremental backup of volume '02/27/2007.dmp' ----------->

Incremental backup of volume '02/27/2007.log'----------> This is supposed to be the log file
Tue 02/27/2007

Windows BatchWindows Server 2003

Avatar of undefined
Last Comment
LindaC
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

Following your suggestion the dump file was written as:
02-27-2007.DMP , but I want to be written as oem10g_2-27-2007.dmp.
Do you know how to do it, what do I have to add to what the variable newDate in order to get what I want?
Avatar of sirbounty
sirbounty
Flag of United States of America image

Just us
oem10g_%newDate%.dmp
for the filename.
Avatar of sirbounty
sirbounty
Flag of United States of America image

Happy to help - thanx for the grade! :^ )
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

It worked marvelous!
Thank you for sharing your talent/ knowledge !
Windows Server 2003
Windows Server 2003

Windows Server 2003 was based on Windows XP and was released in four editions: Web, Standard, Enterprise and Datacenter. It also had derivative versions for clusters, storage and Microsoft’s Small Business Server. Important upgrades included integrating Internet Information Services (IIS), improvements to Active Directory (AD) and Group Policy (GP), and the migration to Automated System Recovery (ASR).

129K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo