I am creating a batch file to take regular backups. In that batch file I have to create a folder with sysdate. How to do that can anyone suggest me?
Printable View
I am creating a batch file to take regular backups. In that batch file I have to create a folder with sysdate. How to do that can anyone suggest me?
save the script in fdate.bat
DATE /t >dt.txt
COPY tday.txt+dt.txt dat.bat
CALL dat.bat
SET today=%today: =%
SET today=%today:/=%
MKDIR C:\%TODAY%
note: u have to create tday.txt,dt.txt,dat.bat
It is creating date in dt.txt correctly. It is showing following error message
C:\>MKDIR C:\/=
The syntax of the command is incorrect.
[QUOTE=krishnaindia2007;23767]It is creating date in dt.txt correctly. It is showing following error message
C:\>MKDIR C:\/=
The syntax of the command is incorrect.[/QUOTE]
In previous post where i used mkdir c:\/ ... ?
u need to write all the below steps (6 steps) in fdate.bat and save it
DATE /t >dt.txt
COPY tday.txt+dt.txt dat.bat
CALL dat.bat
SET today=%today: =%
SET today=%today:/=%
MKDIR C:\%TODAY%
and u need to create tday.txt,dt.txt,dat.dat files and save it in c:\
I have written all the six lines in the same batch file. while executing the batch file It is showing message
C:\>MKDIR C:\/=
The syntax of the command is incorrect.
Execute each statement separately in cmd and check it whether they are
wroking in cmd correctly or not, becasuse bat file is executed correctly in my
system. other wise use the simple command
mkdir %date:/=%
hi
@susarlasirisha
can you explain your 6 steps...i am unable to understand :confused:why you created date in one file and copy that in another finally call that one. I am confused.
DATE /t >dt.txt --This is ok
COPY tday.txt+dt.txt dat.bat <[I]i am strucked here[/I]>
CALL dat.bat < [I]now dat.bat has only one line . that too 'Date' not command, why did u call . this? [/I]>
[B][COLOR="DarkOrange"]Jaya[/COLOR][/B]
try to use this in the batch file
[code]
for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set fdate=%%a%%b%%c
for /f "tokens=1,2,3,4,5 delims=: " %%a in ('time /t') do set ftime=%%a%%b%%c%%d%%e
exp userid=user_name/password@orcl
file=F:\Debasis\data\backup%fdate%%ftime%.dmp
log=F:\Debasis\data\backup%fdate%%ftime%.log
[/code]
simply use this command
md %date:~7,2%%date:~4,2%%date:~10,4%
hi all
well it's working...thank you susarlasireesha
what i understood is
[B]md %date:~7,2%%date:~4,2%%date:~10,4%
[/B]
is combination of 3 parts
[B]%date:~7,2% -> [For date]
%date:~4,2% -> [For month]
%date:~10,4% -> [For year][/B]
actually [I][B][COLOR="Gray"]date[/COLOR][/B][/I] give us [B][COLOR="Red"]Wed 02/20/2008[/COLOR][/B]
toal [B]12[/B] characters ( 0 to 11 )
so in [B]%date:~7,2%[/B] ..... [B]7[/B] means starting position and [B]2[/B] means number of characters. so it will take [B]2[/B] characters starting from [B]7[/B]th position. that means date( here 20 )
remaining two also same procedure.
[B][COLOR="DarkOrange"]Jaya [/COLOR][/B]:)