Jump to content

Incremental version numbers?


Recommended Posts

I'd like to keep track of every ISO I make of my restore disk. To keep version numbers, and easily identify the different versions.

What do I need to do to make the batch listed below call the old version number (from a text file, likely), add 1 to the number, store this to memory as a variable, and write the new version number over the old in the text file, then use the version number variable in the iso file name?

This way, if I have multiple revisions of the iso saved, it's easy to tell just what 'version' is most recent/experimental.

Thanks,

Gai-jin

CLS
@echo off
TITLE Creating ISO Image of Windows XP Professional
ECHO.
ECHO Removing any possible attributes set on C:\Workshop\Restore CDs\CD Set\CD1 and its subfolders...
attrib -R -H C:\Workshop\restor~1\2.0\CDSET~1\CD1 /S /D
ECHO.
ECHO Creating ISO...
CDIMAGE.EXE -lXPdisc1 -t12/31/2002,12:00:00 -h -j1 -m -bxpboot.img C:\Workshop\restor~1\2.0\CDSET~1\CD1 C:\Workshop\restor~1\2.0\XPSp2R1.ISO
ECHO.
ECHO.
ECHO Removing any possible attributes set on C:\Workshop\Restore CDs\CD Set\CD2 and its subfolders...
attrib -R -H C:\Workshop\restor~1\2.0\CDSET~1\CD2 /S /D
ECHO.
ECHO Creating ISO...
CDIMAGE.EXE -lXPdisc2 -t12/31/2002,12:00:00 -h -j1 -m -bxpboot.img C:\Workshop\restor~1\2.0\CDSET~1\CD2 C:\Workshop\restor~1\2.0\XPSp2R2.ISO
ECHO.
PAUSE
EXIT

Link to comment
Share on other sites


Heres a batch file that does something like what you are trying to do. It looks at a three digit number in a text file (file path/name specified in batch) and increments it and then writes it back out to the file. In the mean time the old and new values are stored in two variables which could be used elsewhere in the script (e.g. in your CDIMAGE commands). I hope this helps you.

@ECHO OFF
CLS
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

:: Define the name of the file containing the version number
SET VERFILE=VER.TXT

:: Make sure the version file exists
IF NOT EXIST %VERFILE% GOTO ERROR

:: Check current version (from file)
FOR /F "delims=" %%F IN (%VERFILE%) DO SET CURRVER=%%F

:: Increment the version number
IF "%CURRVER%" LSS "009" (
  SET /A TMP1=%CURRVER:~-1%+1
  SET NEWVER=%CURRVER:~0,-1%!TMP1!
) ELSE IF "%CURRVER%" EQU "009" (
  SET /A TMP1=%CURRVER:~-1%+1
  SET NEWVER=%CURRVER:~0,-2%!TMP1!
) ELSE (
  SET /A TMP1=%CURRVER:~-2%+1
  SET NEWVER=%CURRVER:~0,-2%!TMP1!
)

:: Write the new version number to a temporary file
ECHO %NEWVER%>>%VERFILE:~0,-4%.TMP

:: Update the version file with the temporary one
XCOPY /Q /Y %VERFILE:~0,-4%.TMP %VERFILE% >> NUL
DEL %VERFILE:~0,-4%.TMP >> NUL

:: Done, exit the script
GOTO END


:ERROR
ECHO An unexpected error occured during this operation.


:END
ECHO.
PAUSE
EXIT

Regards,

Matt

Link to comment
Share on other sites

I use VB to update a marker file in the root of the C:\ drive.

An example file is called Build-xp.01.01.000 and the 000 will go to 001

' Rename the build marker file
OPTION EXPLICIT

Dim fso
Dim Folder, OldFile,NewFile, FileColl

Dim MajorMinor
Dim BuildNumber
Dim FolderPath

Set fso = CreateObject("Scripting.FileSystemObject")

wscript.echo "Finding Marker file"
FolderPath = "..\XP With SP1\$OEM$\$1"
Set Folder = fso.GetFolder(FolderPath)
Set FileColl = Folder.Files
For Each OldFile in FileColl
 If Left(OldFile.name,8)="Build-XP" Then
   WScript.echo "Old Marker " & OldFile.Name    
   MajorMinor = Left(OldFile.name,14)
   BuildNumber = Right(OldFile.Name,3)
   BuildNumber = BuildNumber + 1
   NewFile = MajorMinor & "." & Right("000" & BuildNumber,3)
   WScript.Echo "Renaming to " & NewFile
   fso.MoveFile FolderPath & "\" & OldFile.Name, FolderPath & "\" & NewFile
   Exit For
 End If
Next

Set fso=Nothing
wscript.echo "Finished"

This gets called as part of the ISO Creation command file using:

ECHO Updating Build Number
CSCRIPT RENAME.VBS
ECHO Creating ISO...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...