Hi,

asked by a user here is a script for creating thumbnails (CreateThumbnails.cmd):
Code:
@echo off
rem Thumbnail creation with IrfanView
cls
setlocal
echo Create thumbnails
echo -----------------

rem ************
rem * Settings *
rem ************

rem Thumbnail width
set width=80

rem File extension
set filetype=*.jpg

rem JPEG quality
set quality=50

rem Source path of the pictures
set source=R:\pics

rem Prefix for thumbnails
set prefix=TN-

rem Thumbnail sub directory name
set thumbnail=thumbnail

rem Silent mode?
rem Set silent to 0 means see all messages
rem Set silent to 1 means see just just the processed directories
rem Set silent to 2 means see no messages
set silent=0

rem Create thumbnails always
rem Set createallways to 0 if you like to create thumbnails for new files only
rem Set createallways to 1 to create new and overwrite existing thumbnails
set createallways=0

rem Resize what?
rem set resize=/resize=(%width%,%width%)
set resize=/resize_long=%width%
rem set resize=/resize_short=%width%

rem Path to Irfan view
if /i "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (
 rem Path to IrfanView on x64 Windows
 set iview="%ProgramFiles(x86)%\IrfanView\i_view32.exe"
) else (
 rem Path to IrfanView on x86 Windows
 set iview="%ProgramFiles%\IrfanView\i_view32.exe"
)
if not exist %iview% goto noIview

rem *******************
rem * Script function *
rem *******************
rem Check source path
if not exist "%source%\." goto nosource

rem Process the source directory
for /f "delims=" %%a in ('pushd "%source%"^&cd^&popd') do call :createthb "%%~na" "%%a"

rem Get directory structure and call the routine for converting
for /f "delims=" %%a in ('dir /s /b /ad "%source%"') do call :createthb "%%~na" "%%a"

echo Finished.
goto end

rem Create the thumbnails
:createthb
rem First check if we are not in a thumbnail directory
if /i "%~1" equ "thumbnail" goto :eof

rem Check if the thumbnail subdirectory exists
if not exist "%~2\thumbnail" md "%~2\thumbnail"

rem Create thumbnails
if "%silent%" leq "1" echo Processing "%~2"...
for /f "delims=" %%b in ('dir /b /a-d "%~2\%filetype%"') do call :createthb2 "%~2" "%%~b"
goto :eof

rem Create thumbnail if it does not exist
:createthb2
rem if thumbnail exist => skip
if exist "%~1\%thumbnail%\%prefix%%~2" (
 if "%silent%" equ "0" echo Thumbnail "%~1\%thumbnail%\%prefix%%~2" for "%~1\%~2" found.
 if "%createallways%" equ "0" goto :eof
)

rem Create thumbnail
if "%silent%" equ "0" echo Creating thumbnail for "%~1\%~2".
start "IrfanView" /wait %iview% "%~1\%~2" /resize=(%width%,%width%) /aspectratio /resample /jpgq=%quality% /convert="%~1\%thumbnail%\%prefix%$F"
goto :eof

rem IrfanView could not be found.
:noiview
echo IrfanView not found in the given path:
echo   %iview%
goto end

rem Source path does not exist
:nosource
echo Source path
echo   %source%
echo not found. Please check the path.
goto end

rem End of the script
:end
pause
endlocal
The script searches for files of type JPG
Code:
set filetype=*.jpg
in the source folder
Code:
set source=R:\pics
It will create thumbnail files of the search result with a size of
Code:
set width=80
Resize the image an set the size like
Code:
set resize=/resize=(%width%,%width%)
for a rectangle,

or a rectangular
Code:
set height=80
set resize=/resize=(%width%,%height%)
or keep the proprtional setting and resize by setting the long side
Code:
set resize=/resize_long=%width%
or the short side
Code:
set resize=/resize_short=%width%
and set the JPEG quality to 50 percent
Code:
set quality=50
Store the thumbnails in subdiretories of the original files named thumbnail
Code:
set thumbnail=thumbnail
and use the prefix "TN-"
Code:
set prefix=TN-
Create the thumbnails always
Code:
set createallways=1
or just for new files
Code:
set createallways=0
If you want to see some progress messages you may
Code:
set silent=0
for all messages or

use this line to see just the processed directories
Code:
set silent=1
or use this if you do not like to see any processing message
Code:
set silent=2
Have fun
Nils