Created
July 6, 2015 16:42
-
-
Save tzkmx/1b499765e3cfea9e8eb9 to your computer and use it in GitHub Desktop.
Creates empty log file dated using mysql output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
REM mysql DATE_FORMAT tokens: %W (weekday name) %M (month name) %d (month day) %Y (year) | |
SET timeformatstring='%%W_%%M-%%d-%%Y' | |
REM FOR /F takes output from `time /t` and tokenizes it in %A %B and %C | |
FOR /F "usebackq tokens=1-4 delims=: " %%A IN (`time /t`) DO ( | |
REM takes localized output from mysql NOW() string built with tokens in %timeformatsring% | |
FOR /F "usebackq tokens=1-2 skip=1 delims=| " %%H IN (`mysql -h %dbHost% -u %dbUser% -p%dbPass% -e "SET @@lc_time_names='es_MX'; SELECT UPPER(DATE_FORMAT(NOW(), %timeformatstring%));"`) DO ( | |
ECHO Creating log file with date: %%H and time: %%A%%B%%C | |
REM CMD equivalent of Unix touch? http://superuser.com/a/764725 | |
TYPE NUL >> %%H_%%A%%B%%C && COPY %%H_%%A%%B%%C +,, | |
REM (TYPE NULL create empty file && COPY _ +,, update timestamp) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment