@ECHO OFF :: Script version SET MyVer=1.10 :: Windows NT 4 or later required IF NOT "%OS%"=="Windows_NT" GOTO Syntax :: Check if help is required IF NOT "%~1"=="" GOTO Syntax :: Localize variables SETLOCAL :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: Modify your settings below this line :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: SET Title=My Pictures SET FileSpec=*.jpg SET PictWidth=800 SET PictHeight=600 SET ThumbWidth=150 SET ThumbHeight=120 SET PhotoQuality=80 SET ThumbQuality=50 SET IndexCols=4 SET IndexRows=3 SET HomeURL=../index.html :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: Do not make any changes below this line :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: Use default values where none were specified IF NOT DEFINED FileSpec SET FileSpec=*.jpg IF NOT DEFINED PictWidth SET PictWidth=800 IF NOT DEFINED PictHeight SET PictHeight=600 IF NOT DEFINED ThumbWidth SET ThumbWidth=150 IF NOT DEFINED ThumbHeight SET ThumbHeight=120 IF NOT DEFINED PhotoQuality SET PhotoQuality=80 IF NOT DEFINED ThumbQuality SET ThumbQuality=50 IF NOT DEFINED IndexCols SET IndexCols=4 IF NOT DEFINED IndexRows SET IndexRows=3 IF NOT DEFINED HomeURL SET HomeURL=../index.html :: Check if irfanView is installed, and where START /WAIT REGEDIT.EXE /E "%Temp%.\i_view32_test.dat" "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\IrfanView" IF NOT EXIST "%Temp%.\i_view32_test.dat" GOTO Syntax FOR /F "tokens=2 delims==" %%A IN ('TYPE "%Temp%.\i_view32_test.dat" ^| FIND.EXE /I "UninstallString"') DO SET IView="%%~dpAi_view32.exe" DEL "%Temp%.\i_view32_test.dat" :: Create directory structure for web pages ( MD web MD web\jpgs MD web\thmb MD web\html ) >NUL 2>&1 :: Copy navigation buttons ( COPY "%~dp0first.gif" web\*.* COPY "%~dp0prev.gif" web\*.* COPY "%~dp0home.gif" web\*.* COPY "%~dp0index.gif" web\*.* COPY "%~dp0next.gif" web\*.* COPY "%~dp0last.gif" web\*.* ) >NUL 2>&1 :: Convert and compress photos, and create thumbnails ECHO Resizing and compressing pictures . . .>CON %IView% "%cd%\%FileSpec%" /resize=(%PictWidth%,%PictHeight%) /resample /aspectratio /convert="%cd%\web\jpgs\*.jpg" /jpgq=%PhotoQuality% ECHO Creating thumbnails . . .>CON %IView% "%cd%\%FileSpec%" /resize=(%ThumbWidth%,%ThumbHeight%) /resample /aspectratio /convert="%cd%\web\thmb\*.jpg" /jpgq=%ThumbQuality% FOR %%A IN ("%cd%\web\jpgs\*.jpg") DO REN "%cd%\web\thmb\%%~nxA" t_%%~nxA :: Get file name of first picture FOR /F "tokens=1* delims=[]" %%A IN ('DIR/A-D/B/O web\jpgs\*.jpg ^| FIND.EXE /N "." ^| FIND.EXE "[1]"') DO ( CALL SET FirstPic=%%~nB ) :: Get number and file name of last picture FOR /F "tokens=1* delims=[]" %%A IN ('DIR/A-D/B/O web\jpgs\*.jpg ^| FIND.EXE /N "."') DO ( CALL SET LastNum=%%A CALL SET LastPic=%%~nB ) :: Create an HTML page for each individual picture FOR /F "tokens=1* delims=[]" %%A IN ('DIR/A-D/B/O web\jpgs\*.jpg ^| FIND.EXE /N "."') DO ( CALL :CreateHTML %%A %%~nxB > web\%%~nB.html ) :: Create index pages CALL :CreateIndexPages :: Move all new files to a single directory and remove temporary directories ( MOVE web\jpgs\*.* web RD web\jpgs MOVE web\html\*.* web RD web\html MOVE web\thmb\*.* web RD web\thmb ) >NUL 2>&1 :: Show the result START web\index1.html :: End of main program ENDLOCAL GOTO:EOF :CreateHTML SET Num=%1 SET Pic=%~n2 ECHO Creating %Pic%.html . . .>CON SET /A PrevNum = %Num% - 1 SET /A NextNum = %Num% + 1 FOR /F "tokens=2 delims=[]" %%A IN ('DIR/A-D/B/O web\jpgs\*.jpg ^| FIND.EXE /N "." ^| FIND.EXE "[%PrevNum%]"') DO (SET PrevPic=%%~nA) IF %Num%==1 (SET PrevPic=) FOR /F "tokens=2 delims=[]" %%A IN ('DIR/A-D/B/O web\jpgs\*.jpg ^| FIND.EXE /N "." ^| FIND.EXE "[%NextNum%]"') DO (SET NextPic=%%~nA) IF %Num%==%LastNum% (SET NextPic=) SET /A PicsPerPage = %IndexCols% * %IndexRows% SET /A LastIndexNum = ( %LastNum% + %PicsPerPage% - 1 ) / %PicsPerPage% :: Write HTML page code ECHO ^ ECHO ^ ECHO ^
ECHO ^^ ^
ECHO. CALL :CreateNavigationBar ECHO. ECHO ^^ ^ | ECHO ^
^^ | ECHO ^
^ ^ | ECHO ^
%Pic%^ | ECHO ^
---|
^ ^ | ECHO ^
^ ^ ^ ^ ^ | ECHO ^^ ^ ^ ^ ^ | ) ELSE ( ECHO ^^^^^ | ECHO ^^^^^ | ) SET /A IndexNum = ( %Num% + %PicsPerPage% - 1 ) / %PicsPerPage% ECHO ^^^^^ | IF "%Num%"=="%LastNum%" ( ECHO ^^ ^ ^ ^ ^ | ECHO ^^ ^ ^ ^ ^ | ) ELSE ( ECHO ^^^^^ | ECHO ^^^^^ | ) ECHO ^
^ ^
ECHO. CALL :CreateIndexNavBar ECHO. ECHO ^^ ^ ^ ^ ^ | ECHO ^^ ^ ^ ^ ^ | ) ELSE ( ECHO ^^^^^ | ECHO ^^^^^ | ) ECHO ^^^^^ | IF "%IndexNum%"=="%LastIndexNum%" ( ECHO ^^ ^ ^ ^ ^ | ECHO ^^ ^ ^ ^ ^ | ) ELSE ( ECHO ^^^^^ | ECHO ^^^^^ | ) ECHO ^