469,150 Members | 1,950 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,150 developers. It's quick & easy.

batch file script

147 100+
Hi,
my batch file named cpf.bat

Expand|Select|Wrap|Line Numbers
  1.      COPY C:\Progra~1\Micros~1\MSSQL\BACKUP\acaddb.bak F:\DATABACKUP\acaddb.bak
  2.  
Its working fine.

But in this ,i should append current date
.please help me ? how i should append current date with the filename while copying into my F drive.


Thanks in advance.................
Jan 6 '10 #1
8 2020
RedSon
5,000 Expert 4TB
you can do something like

set MONTH=%date:~4,2%
set DAY=%date:~7,2%

and then use MONTH and DAY in your file path. Or you can just use %date%. Try echo %date% and see what it gives you.
Jan 6 '10 #2
santhanalakshmi
147 100+
hi,

now, i am changing my batch file script as now :

COPY C:\Progra~1\Micros~1\MSSQL\BACKUP\acaddb.bak F:\DATABACKUP\acaddb%date:~4,2%-%date:~7,2%-%date:~10%.bak
now my batch file is not running .......please help me out.
Jan 7 '10 #3
RedSon
5,000 Expert 4TB
if you do "echo %date%" in your command window what happens?

Instead of calling date, assign it to a variable like I showed you.
Jan 7 '10 #4
santhanalakshmi
147 100+
hi,
what you have told according to that i have changed my batch file like this:

set val=echo %date%
COPY C:\Progra~1\Micros~1\MSSQL\BACKUP\acaddb.bak F:\DATABACKUP\acaddb%val.bak


my file is copying in the F drive ....but under the name like "acaddbval".........date is not getting append to the "acaddb" ......
Jan 7 '10 #5
Banfa
9,061 Expert Mod 8TB
You have missed the ending % from %val%
Jan 7 '10 #6
santhanalakshmi
147 100+
hi,

i tried that too also......if i add % at the end of the variable.......script not at all running......(ie not copying from C drive to F drive).please help me out
Jan 7 '10 #7
Banfa
9,061 Expert Mod 8TB
set val=echo %date%

should be

set val=%date%
Jan 7 '10 #8
santhanalakshmi
147 100+
hi,
what you told,i have tried like this also...but its useless.
Jan 8 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Christian-Josef Schrattenthaler | last post: by
3 posts views Thread by emman_54 | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.