Torque build update scripts
by D Player · 11/16/2002 (3:18 pm) · 0 comments
If you're like me, you probably have two CVS repositories. One for devs, and one for artists without a Torque license. Now perhaps there is a way to do this in a single repository but that is another matter. If your CVS repository is local you could also just copy the entire example folder and del /s *.dso (and other types). And hell, the whole thing would be much better done in Perl.
However, here is a one way update BATch script that probably only runs on Windows XP (or 2000 I think) because of the for options (which can probably be rewritten to work on older Windows OSes).
requirements: touch utility in current path if you want to use the date option
Usage: buildUpdate.bat path1 path2 [y|date]
will compare files in both paths by date and binary compare
y will update path2 from path1, adding and updating files and folders as needed
date will only update dates on identical files (but don't do this)
---------------buildUpdate.bat------------------------
@echo off
rem INPUT:
rem %1 folder to CD to
rem %2 folder containing mirror copy of CD folder
rem %3 y for fix, date to only update dates on identical files (but don't do this)
rem echo "%1" "%2" %3
if "%2"=="" goto NoParamEnd
if not exist %1 goto NotExistEnd
if not exist %2 goto NotExistEnd
if "%3"=="" echo Not going to change anything here
cd %1
for /F "usebackq delims=$" %%f in ('dir /a:d /b') do @call "%~fnx0" "%%~f" "%~2\%%~f" %3
call "%~p0buildUpdateFiles.bat" "%~2" %3
cd..
goto end
:help
echo usage: buildUpdate path1 path2 [y]
echo will compare files in both paths by date and binary compare
echo y will update path2 from path1, adding and updating files as needed
echo date will only update dates on identical files (but don't do this)
:NoParamEnd
if "%1"=="--help" goto help
echo Not enough parameters!
goto end
:NotExistEnd
echo Path does not exist!
goto end
:OptionalCleanup
rem call this if you need it
goto end
:end
---------------buildUpdateFiles.bat------------------------
@echo off
rem INPUT:
rem %1 folder containing mirror copy of current working directory
rem %2 y for fix
if "%~n1"=="CVS" goto end
if not exist %1 goto Missing
for %%f in (*) do @call "%~p0buildUpdateFiles2.bat" %1 "%%~f" "%~1\%%~f" %2
goto end
:Missing
if "%2" == "y" goto FixMissing
echo MISSING: Folder %1
goto end
:FixMissing
md %1
echo ADDING: Folder %1
call %0 %1 %2
goto end
:end
---------------buildUpdateFiles2.bat------------------------
@echo off
rem INPUT:
rem %1 folder containing mirror copy of current working directory
rem %2 filename
rem %3 fully qualified path to mirror file
rem %4 y for fix
rem yes I know that %1 and %2 are not needed.
if /I "%~x2" == ".dso" goto end
if /I "%~x2" == ".ilk" goto end
if /I "%~x2" == ".ilk" goto end
if /I "%~x2" == ".tsb" goto end
if /I "%~x2" == ".tsw" goto end
if /I "%~x2" == ".gft" goto end
if /I "%~x2" == ".log" goto end
if /I "%~x2" == ".bak" goto end
if /I "%~x2" == ".ml" goto end
if /I %2 == "prefs.cs" goto end
if /I %2 == "banlist.cs" goto end
if /I %2 == "ReadMe.html" goto end
if not exist %3 goto NotExist
if not "%~t3" == "%~t2" goto WrongDate
goto end
:WrongDate
rem echo DATE: %3
rem echo DATE2: "%~t3" != "%~t2"
fc /b %2 %3 > NUL
goto FC%errorlevel%
goto end
:FC0
rem SAME
if "%4" == "date" goto FixSame
goto end
:FC1
rem DIFFERENT
if "%4" == "y" goto FixDifferent
echo DIFFERENT: %3
goto end
:FixSame
touch -c --date="%~t2" %3
goto end
:FixDifferent
echo UPDATING: %3
copy /Y %2 %3 > NUL
goto end
:NotExist
if "%4" == "y" goto FixMISSING
echo MISSING: %~x2 %3
goto end
:FixMISSING
echo ADDING: %~x2 %3
copy /y %2 %3 > NUL
goto end
:end
Alright, if there is any real interest shown I will consider rewriting this in Perl as a 2 way update system. I hope this has enlightened a few of you as to the power of for. It honestly suits my needs right now though :)
However, here is a one way update BATch script that probably only runs on Windows XP (or 2000 I think) because of the for options (which can probably be rewritten to work on older Windows OSes).
requirements: touch utility in current path if you want to use the date option
Usage: buildUpdate.bat path1 path2 [y|date]
will compare files in both paths by date and binary compare
y will update path2 from path1, adding and updating files and folders as needed
date will only update dates on identical files (but don't do this)
---------------buildUpdate.bat------------------------
@echo off
rem INPUT:
rem %1 folder to CD to
rem %2 folder containing mirror copy of CD folder
rem %3 y for fix, date to only update dates on identical files (but don't do this)
rem echo "%1" "%2" %3
if "%2"=="" goto NoParamEnd
if not exist %1 goto NotExistEnd
if not exist %2 goto NotExistEnd
if "%3"=="" echo Not going to change anything here
cd %1
for /F "usebackq delims=$" %%f in ('dir /a:d /b') do @call "%~fnx0" "%%~f" "%~2\%%~f" %3
call "%~p0buildUpdateFiles.bat" "%~2" %3
cd..
goto end
:help
echo usage: buildUpdate path1 path2 [y]
echo will compare files in both paths by date and binary compare
echo y will update path2 from path1, adding and updating files as needed
echo date will only update dates on identical files (but don't do this)
:NoParamEnd
if "%1"=="--help" goto help
echo Not enough parameters!
goto end
:NotExistEnd
echo Path does not exist!
goto end
:OptionalCleanup
rem call this if you need it
goto end
:end
---------------buildUpdateFiles.bat------------------------
@echo off
rem INPUT:
rem %1 folder containing mirror copy of current working directory
rem %2 y for fix
if "%~n1"=="CVS" goto end
if not exist %1 goto Missing
for %%f in (*) do @call "%~p0buildUpdateFiles2.bat" %1 "%%~f" "%~1\%%~f" %2
goto end
:Missing
if "%2" == "y" goto FixMissing
echo MISSING: Folder %1
goto end
:FixMissing
md %1
echo ADDING: Folder %1
call %0 %1 %2
goto end
:end
---------------buildUpdateFiles2.bat------------------------
@echo off
rem INPUT:
rem %1 folder containing mirror copy of current working directory
rem %2 filename
rem %3 fully qualified path to mirror file
rem %4 y for fix
rem yes I know that %1 and %2 are not needed.
if /I "%~x2" == ".dso" goto end
if /I "%~x2" == ".ilk" goto end
if /I "%~x2" == ".ilk" goto end
if /I "%~x2" == ".tsb" goto end
if /I "%~x2" == ".tsw" goto end
if /I "%~x2" == ".gft" goto end
if /I "%~x2" == ".log" goto end
if /I "%~x2" == ".bak" goto end
if /I "%~x2" == ".ml" goto end
if /I %2 == "prefs.cs" goto end
if /I %2 == "banlist.cs" goto end
if /I %2 == "ReadMe.html" goto end
if not exist %3 goto NotExist
if not "%~t3" == "%~t2" goto WrongDate
goto end
:WrongDate
rem echo DATE: %3
rem echo DATE2: "%~t3" != "%~t2"
fc /b %2 %3 > NUL
goto FC%errorlevel%
goto end
:FC0
rem SAME
if "%4" == "date" goto FixSame
goto end
:FC1
rem DIFFERENT
if "%4" == "y" goto FixDifferent
echo DIFFERENT: %3
goto end
:FixSame
touch -c --date="%~t2" %3
goto end
:FixDifferent
echo UPDATING: %3
copy /Y %2 %3 > NUL
goto end
:NotExist
if "%4" == "y" goto FixMISSING
echo MISSING: %~x2 %3
goto end
:FixMISSING
echo ADDING: %~x2 %3
copy /y %2 %3 > NUL
goto end
:end
Alright, if there is any real interest shown I will consider rewriting this in Perl as a 2 way update system. I hope this has enlightened a few of you as to the power of for. It honestly suits my needs right now though :)
