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?
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.
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 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 am strucked here>
CALL dat.bat < now dat.bat has only one line . that too 'Date' not command, why did u call . this? >
Jaya
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
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
md %date:~7,2%%date:~4,2%%date:~10,4%
is combination of 3 parts
%date:~7,2% -> [For date]
%date:~4,2% -> [For month]
%date:~10,4% -> [For year]
actually date give us Wed 02/20/2008
toal 12 characters ( 0 to 11 )
so in %date:~7,2% ..... 7 means starting position and 2 means number of characters. so it will take 2 characters starting from 7th position. that means date( here 20 )
remaining two also same procedure.
Jaya