-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnewversion.bat
More file actions
executable file
·39 lines (25 loc) · 947 Bytes
/
newversion.bat
File metadata and controls
executable file
·39 lines (25 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
REM Current version from `VERSION.txt`.
SET VersionFile=%~dp0VERSION.txt
FOR /F "usebackq delims=" %%I IN ("%VersionFile%") DO SET OldVersion=%%I
FOR /F "tokens=1-3 delims=." %%A IN ("!OldVersion!") DO (
SET OldMajorVersion=%%A
SET OldMinorVersion=%%B
SET OldPatchVersion=%%C
)
REM Determine the new version based on the current version and the current date.
FOR /F "tokens=2 delims==" %%I IN ('wmic os get localdatetime /value') DO SET Now=%%I
SET NewMajorVersion=!OldMajorVersion!
SET NewMinorVersion=!Now:~0,8!
IF !OldMinorVersion! LSS !NewMinorVersion! (
SET NewPatchVersion=0
) ELSE (
SET /A NewPatchVersion=!OldPatchVersion! + 1
)
SET NewVersion=!NewMajorVersion!.!NewMinorVersion!.!NewPatchVersion!
REM Update our version file.
ECHO !NewVersion! > "%VersionFile%"
REM Display the old and new versions.
ECHO Old version: !OldVersion!
ECHO New version: !NewVersion!