For/F "tokens = *" % G in ('time/t') do set _ time = % G
Set _ time = % _ time :~ 0, 2%-% _ time :~ 3,2%
Endlocal & SET _ time = % _ time %
Echo % Date :~ 0, 4%-% Date :~ 5, 2%-% Date :~ 8, 2%-% _ time %
Displayed as 2009-02-17-09-15 after execution (example)
The Windows command line is used to obtain the year-month-day-hour-minute-second, which is often used for database backup.
For example, to compress the zbfz data of an oracleuser, ensure that rar35.exe and BAT files are in the same directory ):
For/F "tokens = *" % G in ('time/t') do set _ time = % G
Set _ time = % _ time :~ 0, 2%-% _ time :~ 3,2%
Endlocal & SET _ time = % _ time %
Set _ time = % Date :~ 0, 4%-% Date :~ 5, 2%-% Date :~ 8, 2%-% _ time %
D:. \ exp zfbz/zfbz @ his owner = zfbz file = zfbz _ % _ time %. dmp log = zfbz _ % _ time %. Log
Rar35 A-DF zfbz_%_timestamps .rar zfbz _ % _ time %. dmp zfbz _ % _ time %. Log
The zfbz__2009-02-17-09-15.rar file is generated in the final process.