@echo off set overwrite=false if %1==true set overwrite=true ::SET THE REST OF DIRECTORIES ::------------------------------------------ set startDir=%cd% set source3party=%startDir%\graphics\3rdparty set sourceEps=%startDir%\graphics\eps set sourceBitmap=%startDir%\graphics\bitmap set dest=%startDir%\graphics\img-src ::Get possible locations where apps could be installed ::------------------------------------------------------- for /f "delims=" %%a in (C:\WINDOWS\system32\locations.txt) do if exist %%a set workingPath=%%a :set epsToPdfScript="%workingPath%\texmf\miktex\bin\epstopdf.exe" set epsToPdfScript="C:\Program Files\MiKTeX 2.7\miktex\bin\epstopdf.exe" set jpgToEpsScript="%workingPath%\netpbm\bin\jpegtopnm.exe" set tifToEpsScript="%workingPath%\netpbm\bin\tifftopnm.exe" set pngToEpsScript="%workingPath%\netpbm\bin\pngtopnm.exe" set pnmtopsScript="%workingPath%\netpbm\bin\pnmtops.exe" ::Deleting all files in the destination folder ::-------------------------------------------- echo.configuration echo.------------- if %overwrite%==true ( echo overwrite enabled echo deleting all files from: %dest% rmdir /Q /S %dest% mkdir %dest% ) else ( echo overwrite disabled ) ::@echo on ::FOR 3RDPARTY EPS - (only if overwriting) - CONVERT FILES FROM EPS TO PDF + COPY BOTH ::------------------------------------------------------- echo. echo.starting 3rdparty eps to pdf echo.------------------- cd %source3party% for /f "delims=" %%a in ('dir /B /s /a-d *.eps') do ( call :part1 %%a ) ::FOR POSTSCRIPT - CONVERT FILES FROM EPS TO PDF + MOVE UNCHANGED ::------------------------------------------------------- echo. echo.starting eps to pdf echo.------------------- cd %sourceEps% for /f "delims=" %%a in ('dir /B /s /a-d *.eps') do ( call :part1 %%a ) ::FOR BITMAPS - CONVERT BITMAPS TO EPS + MOVE UNCHANGED ::------------------------------------------------------- echo. echo.starting jpg to eps echo.------------------- cd %sourceBitmap% for /f "delims=" %%a in ('dir /B /s /a-d *.jpg') do ( call :part2 %%a %jpgToEpsScript% ) echo. echo.starting png to eps echo.------------------- cd %sourceBitmap% for /f "delims=" %%a in ('dir /B /s /a-d *.png') do ( call :part2 %%a %pngToEpsScript% ) echo. echo.starting tif to eps echo.------------------- cd %sourceBitmap% for /f "delims=" %%a in ('dir /B /s /a-d *.tif') do ( call :part2 %%a %tifToEpsScript% ) echo. cd %startDir% pause goto :eof ::---------------------------------------------------- ::END OF MAIN ROUTINE ::---------------------------------------------------- ::SUPPORT SUBROUTINE FOR THE FIRST PART OF SCRIPT ::------------------------------------------------ :part1 set inFull=%1 set outFull=%inFull:~0,-4%.pdf set in=%~nx1 set out=%in:~0,-4%.pdf if %overwrite%==false ( if exist %dest%\%out% ( if exist %dest%\%in% ( echo SKIPPED %in% -- %out% goto :eof ) ) ) %epsToPdfScript% %inFull% ping -n 1 127.0.0.1 >nul set err=0 if %errorlevel%==1 set err=1 if %err%==0 (ECHO.DONE %in% -- %out%) else (ECHO.ERROR %in% -- %out%) move %outFull% %dest% copy %inFull% %dest% >Nul set errorlevel=0 goto :eof ::SUPPORT SUBROUTINE FOR THE SECOND PART OF SCRIPT ::------------------------------------------------ :part2 set inFull=%1 set outFull=%inFull:~0,-4%.eps set in=%~nx1 set out=%in:~0,-4%.eps if %overwrite%==false ( if exist %dest%\%out% ( if exist %dest%\%in% ( echo SKIPPED %in% -- %out% goto :eof ) ) ) %2 %inFull% | %pnmtopsScript% -nocenter -equalpixels -dpi 72 -noturn -rle - > %outFull% ping -n 1 127.0.0.1 >nul set err=0 if %errorlevel%==1 set err=1 if %err%==0 (ECHO.DONE %in% -- %out%) else (ECHO.ERROR %in% -- %out%) ::echo %outFull% ::echo %dest% ::if exist %outFull% echo.EXIST ::pause move %outFull% %dest% copy %inFull% %dest% >Nul set errorlevel=0 goto :eof