Link to home
Create AccountLog in
Avatar of softbless
softbless

asked on

Batch/bat file modification

Hi Guys,

I have this batch file in windows to dump mysql database. And it's working. The problem is, i want to add date and time to the file. So instead dump1.sql, i want it to have file name : dump1-YYYY-MM-DD-HH-MM.sql

Please revise this bat script.


REM [at] echo off
"C:\Alfresco\mysql\bin\mysqldump" -u root -pPASSWORD alfresco > "C:\dump1.sql"

Open in new window

Avatar of Hammo777
Hammo777

Avatar of amit_g
@echo off

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set timestr=%d:~6,4%-%d:~0,2%-%d:~3,2%-%t:~0,2%-%t:~3,2%

"C:\Alfresco\mysql\bin\mysqldump" -u root -pPASSWORD alfresco > "C:\dump1-%timestr%.sql"
Avatar of softbless

ASKER

@amit:

It give error saying :

The filename, directory name or volum label syntax is incorrect
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks