BATch-Dateien - andere Kommandozeilentools

Auswahl weiterer Kommandozeilentools, die nicht zum Umfang von MS Windows gehören.

Liste weiterer Kommandozeilentools

In dieser Rubrik werden verschiedene Kommandozeilentools aufgelistet, die sich ebenso in Batch-Dateien verwenden lassen. Es sind zumeist Portierungen bekannter Unix-Kommandozeilentools oder aber Freeware für Windows.
Alle genannten Programme gehören nicht(!) zum Umfang von MS Windows.

WIP:

Beispiele: Bildgrösse ändern

Um ein Foto einer Digitalkamera für die Verwendung auf der Webseite aufzubereiten, werden in einem Unterverzeichnis "_pics4web" 2 Grafiken angelegt:
  • eine Grafik in 800x600 Pixel
  • ein Thumbnail in 100x75 Pixel
Es werden dazu 2 Aufrufe für je eine Abmessung gemacht.
nconvert -resize [Breite] [Höhe] -q [Qualität] -i -rmeta -o [Ausgabedatei] [Original-Datei]
Der nachfolgende Wrapper kann mit beliebig vielen zu konvertierenden jpg-Dateien als Parameter aufgerufen werden.

Snippet:
@echo off
rem ----------------------------------------------------------------------
::
::  wrapper for NCONVERT
::  Axel Hahn - http://www.axel-hahn.de/
::
rem ----------------------------------------------------------------------
::  V1.0 - 2001
::  V1.1 - 2003-05-29  extensions: creates 2 pics: webpictures and thumbnails
::  V1.2 - 2004-02-16  extensions: added params "-i -rmeta"
rem ----------------------------------------------------------------------


rem ----------------------------------------------------------------------
::  CONFIG
rem ----------------------------------------------------------------------

        :: directory path of NCONVERT
        set NCONVERT=e:\grafik\xnview\nconvert.exe

        :: name of subdirectory where the images will be created.
        :: no slashes, please - mkdir doesn't like it.
        set subdir=_pics4web

        :: parameters for NCONVERT (image size + quality + outputfile)
        :: set PARAMS1=-resize 800 600 -q 50 -o "%subdir%\800x600_%%.jpg"
        set PARAMS1=-resize 800 600 -q 50 -i -rmeta -o "%subdir%\%%.jpg"
        set PARAMS2=-resize 100 75  -q 50 -i -rmeta -o "%subdir%\index_%%.jpg"

        :: STOP - thats all to configure

        set LINE=-------------------------------------------------------------------------------


rem ----------------------------------------------------------------------
::  before we start: some checks...
rem ----------------------------------------------------------------------

        echo %LINE%
        echo create pictures 4 web - V1.2
        echo %LINE%

        if exist %NCONVERT% goto CHECKPARAM
        goto ERROR01

        :CHECKPARAM
        if "%1"=="" goto USAGE

        :CHECKINFILE
        if exist %1 goto COPY
        goto ERROR02


rem ----------------------------------------------------------------------
::  let's go!
rem ----------------------------------------------------------------------

        :COPY
        echo -- creating directory "%subdir%" ...
        mkdir %subdir% >nul
        :: copy %1 %subdir%
        :: cd %subdir%

        echo -- converting with [%PARAMS1%]
        %NCONVERT% %PARAMS1% %1

        echo -- converting with [%PARAMS2%]
        %NCONVERT% %PARAMS2% %1

        echo %LINE%
        :: cd ..

        if "%2"=="" goto ENDE
        shift 1
        goto CHECKINFILE

        :CONVERT
        :: cd %subdir%
        :: %NCONVERT% %PARAMS% *.*

        cd ..
        goto ENDE


rem ----------------------------------------------------------------------
::  errors
rem ----------------------------------------------------------------------

        :ERROR01
        echo ERROR:
        echo The following executable was not found:
        echo %NCONVERT%
        echo Correct the path please - therefore edit the following file:
        echo "%0"
        goto USAGE

        :ERROR02
        echo ERROR: The file "%1" was not found!
        goto USAGE

        :USAGE
        echo.
        echo SYNTAX: %0 [imagefile(s)]
        echo press any key...
        pause >nul
        exit 1


rem ----------------------------------------------------------------------
::  the end of all
rem ----------------------------------------------------------------------

        :ENDE
        echo %0 was terminated.
        echo press any key...
        pause >nul
        echo %LINE%


rem ----------------------------------------------------------------------
::  EOF
rem ----------------------------------------------------------------------