Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Automatic printing

  1. #1

    Question Automatic printing

    Hello together,

    I have a question regarding the printing functionalities in Irfanview. Is there the possibility that Irfanview monitors a directory on a PC and automatically starts to print new pictures?

    A short process description :

    - digital camera takes a photo
    - photo will be transfered to the PC in a defined directory
    - Irfanview checks permanently for new pictures in this directory and prints this picture once on a printer

    Thanks for your help!

    Ciao Goose777

  2. #2
    Moderator
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    855
    Version
    IrfanView 4.51
    OS
    64-bit Win 10
    CPU Cores
    8

    Default

    Hi,

    IrfanView won't do this.
    It should be possible with a windows batch file to do this since IrfanView can be started from command line and triggerd to print a file.
    There are some few things which have to be checked, i.e. how fast are the images copied there, so there might be a timing problem.
    What should be done with the printed images? Deleted or moved?

    I think I can write you a script.

    Regards
    Nils

  3. #3

    Default

    Hi Nils,

    and thanks for your quick answer. The "program" or batch file should do the following steps:

    It should

    - the batch file should scan a defined directory every 10 seconds for jpg/jpeg files
    - in an additional txt file all printed pictures a saved with their filename
    - if the script detects a new file resp. a file which has not been save in the txt-file, it will save the printed file in the texfile for later checks (just the name) and afterwards sends the picture to the standard printer
    - the pictures should not be touched by the script (delete or move), because the should be displayed via a TFT-screen / Irfanview at the same time.

    I think, that are all necessary steps to steer the printing. Generelly 16 megapixel picture will be processed.

    If you need more infos, feel free to ask :-)

    Ciao Goose777

  4. #4
    Moderator
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    855
    Version
    IrfanView 4.51
    OS
    64-bit Win 10
    CPU Cores
    8

    Default

    Hi,

    try this script.
    You have to modify some lines.
    The directory which you like to have scanned:
    Code:
    rem Directory to be scanned
    set scandir=R:\Pictures
    Maybe the name and path of the text files used for logging the printed files:
    Code:
    rem Text file to keep file names of printed files
    set printed="%scandir%\PrintedWithIrfanView.txt"
    If you have a special path running IrfanView then the detection will fail. So remove the "rem" and modify the path to the i_view32.exe:
    Code:
    rem set iview="D:\tools\i_view32.exe"
    Save this script as something like "PrintLoop.cmd"
    Code:
    @echo off
    rem ******************************
    rem * IrfanView PrintLoop script *
    rem ******************************
    rem This script checks a given directory for given picure types and print them.
    setlocal
    
    rem ************
    rem * Settings *
    rem ************
    
    rem Path to Irfan view
    rem If IrfanView is installed in the common program files folder this part
    rem should be usable.
    rem If you have installed IrfanView elsewhere, i.e. in D:\Tools\IV then
    rem just delete these lines and uncomment and modify the set iview line.
    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"
    )
    rem set iview="D:\tools\i_view32.exe"
    if not exist %iview% goto noIview
    
    rem Configure variables
    rem Delay in seconds
    set delay=10
    
    rem Directory to be scanned
    set scandir=R:\Pictures
    
    rem File types (seperate with colon)
    set filetypes=.jpg:.jpeg
    
    rem Text file to keep file names of printed files
    set printed="%scandir%\PrintedWithIrfanView.txt"
    
    rem Use default printer
    set print=/print
    rem Or set a special printer, just replace the printer name and remove the "rem"
    rem set print=/print="My special printer"
    
    
    rem Additional tools
    set choice="%SystemRoot%\system32\choice.exe"
    if not exist %choice% goto nochoice
    set find="%SystemRoot%\system32\find.exe"
    if not exist %find% goto nofind
    
    rem Check if the directory exists
    if not exist "%scandir%" goto noscandir
    rem Change to the input directory
    pushd "%scandir%"
    
    echo Scanning directory
    echo  %scandir%
    echo for new pictures and print them.
    echo.
    rem Do the loop
    :loop
    for /f "delims=" %%a in ('dir /b') do call :check "%%~fa" "%%~xa"
    
    rem Ask for exit or continue scanning
    %choice% /T %delay% /C XC /D C /M "X for exit, C for immediate checking."
    if errorlevel 2 goto loop
    
    rem After finishing go to the end
    popd
    goto end
    
    rem Check file
    :check
    echo %time% Checking...
    rem Check the file type
    echo %filetypes% | %find% /i "%~2" >nul
    if errorlevel 1 goto :eof
    
    rem File type ok
    rem If the text file does not exist, print
    if not exist %printed% call :print %1
    
    rem Check if the file name is already in the text file
    type %printed% | %find% /i %1 >nul
    if errorlevel 1 call :print %1
    goto :eof
    
    :print
    rem Print the picture
    echo Printing %1
    start "IrfanView" /wait %iview% %1 %print% /ini="%scandir%"
    
    rem Appending file name
    (echo %~1)>>%printed%
    goto :eof
    
    :noscandir
    echo %scandir% not found.
    goto end
    
    rem IrfanView could not be found.
    :noiview
    echo IrfanView not found in the given path:
    echo   %iview%
    goto end
    
    rem choice could not be found.
    :nochoice
    echo choice.exe not found in the given path:
    echo   %choice%
    goto end
    
    rem find could not be found.
    :nofind
    echo find.exe not found in the given path:
    echo   %find%
    goto end
    
    rem End of the script
    :end
    endlocal

    You also should have a special ini file, so save this as i_view32.ini into your picture directory:
    Code:
    [Print]
    AutoRotate=1
    Option=1
    Left=0.00
    Top=0.00
    Inches=0
    ScaleX=1.00
    ScaleY=1.00
    Centered=1
    Copies=1
    Orient=1
    Hope this helps.

    Regards
    Nils

  5. #5

    Default

    Hi Nils,

    and wow!!!!!! Thanks a lot for your work. I will try your script at the weekend, because I have to setup a new PC for the Photobox I want to built. I will let you know if everthing is working fine (and I think it will).

    Thanks a lot again and have a nice week.

    Ciao Goose777

  6. #6

    Default

    This is a great script and i use it to print png UPS labels to a Dymo.
    However i get an error when printing multiple images.

    Is it possible to modify the script so it only prints one image at a time, moves it and than scans the folder again or only move the files after they have been printed?
    Last edited by Wilbur13; 09.04.2015 at 04:35 PM.

  7. #7
    Moderator
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    855
    Version
    IrfanView 4.51
    OS
    64-bit Win 10
    CPU Cores
    8

    Default

    Hello,

    sorry for being late. I updated the PrintLoop script, so please give it a try.
    There is a new entry
    Code:
    set printeddir=D:\PicturesPrinted
    If this entry is set with an directory, the pictures will be moved there after they are printed.
    If you like to use the old version, just remove the directory:
    Code:
    set printeddir=
    I added support for IrfanView 64, but haven't had enough time for checking. Please give me some feedback.

    Code:
    @echo off
    rem *********************************
    rem * IrfanView PrintLoop1.1 script *
    rem *********************************
    rem This script checks a given directory for given picure types and print them.
    rem 07.09.2015:
    rem - added  support for 64 bit version of IrfanView
    rem - added possibility to just print one picture, move it and rescan the directory
    
    setlocal ENABLEEXTENSIONS
    
    rem ************
    rem * Settings *
    rem ************
    
    rem Path to Irfan view
    rem If IrfanView is installed in the common program files folder this part
    rem should be usable.
    rem If you have installed IrfanView elsewhere, i.e. in D:\Tools\IV then
    rem just delete these lines and uncomment and modify the set iview line.
    if /i "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (
     if exist "%ProgramFiles%\IrfanView\i_view64.exe" (
      rem Path to 64 Bit IrfanView on x64 Windows
      set iview="%ProgramFiles%\IrfanView\i_view64.exe"
     ) else (
      rem Path to 32 Bit IrfanView on x64 Windows
      set iview="%ProgramFiles(x86)%\IrfanView\i_view32.exe"
     )
    ) else (
     rem Path to 32 Bit IrfanView on x86 Windows
     set iview="%ProgramFiles%\IrfanView\i_view32.exe"
    )
    rem set iview="D:\tools\i_view32.exe"
    if not exist %iview% goto noIview
    
    rem Configure variables
    rem Delay in seconds
    set delay=10
    
    rem Directory to be scanned
    set scandir=D:\Pictures
    
    rem Directory to move pictures after printing
    set printeddir=D:\PicturesPrinted
    
    rem File types (seperate with colon)
    set filetypes=.jpg:.jpeg
    
    rem Text file to keep file names of printed files
    set printed="%scandir%\PrintedWithIrfanView.txt"
    
    rem Use default printer
    set print=/print
    rem Or set a special printer, just replace the printer name and remove the "rem"
    rem set print=/print="My special printer"
    
    
    rem Additional tools
    set choice="%SystemRoot%\system32\choice.exe"
    if not exist %choice% goto nochoice
    set find="%SystemRoot%\system32\find.exe"
    if not exist %find% goto nofind
    
    rem Check if the directory containig the pictures exists
    if not exist "%scandir%" goto noscandir
    
    rem Check if a directory name for printed images is set and the directory exists 
    if "%printeddir%" neq "" (
     if not exist "%printeddir%" (
      mkdir "%printeddir%"
      if not exist "%printeddir%" goto noprinteddir
     )
    )
    
    rem Change to the input directory
    pushd "%scandir%"
    
    echo Scanning directory
    echo  %scandir%
    echo for new pictures and print them.
    echo.
    rem Do the loop
    :loop
    for /f "delims=" %%a in ('dir /b') do call :check "%%~fa" "%%~xa"
    
    rem Ask for exit or continue scanning
    %choice% /T %delay% /C XC /D C /M "X for exit, C for immediate checking."
    if errorlevel 2 goto loop
    
    rem After finishing go to the end
    popd
    goto end
    
    rem Check file
    :check
    echo %time% Checking...
    rem Check the file type
    echo %filetypes% | %find% /i "%~2" >nul
    if errorlevel 1 goto :eof
    rem File type ok
    
    if "%printeddir%" neq "" goto check2
    
    rem If the text file does not exist, print
    if not exist %printed% call :print %1
    
    rem Check if the file name is already in the text file
    type %printed% | %find% /i %1 >nul
    if errorlevel 1 call :print %1
    goto :eof
    
    rem The file have to be moved to the printed directory so there is no need for creating
    rem and checking the "printed" text file.
    :check2
    call :print %1
    move %1 "%printeddir%"
    goto :eof
    
    :print
    rem Print the picture
    echo Printing %1
    start "IrfanView" /wait %iview% %1 %print% /ini="%scandir%"
    
    if "%printeddir%" equ "" goto :eof
    rem Appending file name
    (echo %~1)>>%printed%
    goto :eof
    
    :noscandir
    echo %scandir% not found.
    goto end
    
    :noprinteddir
    echo %printeddir% not found and cannot be created.
    goto end
    
    rem IrfanView could not be found.
    :noiview
    echo IrfanView not found in the given path:
    echo   %iview%
    goto end
    
    rem choice could not be found.
    :nochoice
    echo choice.exe not found in the given path:
    echo   %choice%
    goto end
    
    rem find could not be found.
    :nofind
    echo find.exe not found in the given path:
    echo   %find%
    goto end
    
    rem End of the script
    :end
    endlocal
    Regards
    Nils

  8. #8
    IV Beginner
    Join Date
    Aug 2011
    Posts
    57
    Version
    IrfanView 4.38
    OS
    64-bit Win 7 Professional SP1
    CPU Cores
    8

    Default

    Nice script ...
    but I get an error message:
    command gt not exact written or not found

    Click image for larger version. 

Name:	_PrintLoop-error-gt.jpg 
Views:	166 
Size:	122.9 KB 
ID:	4194

    What is my fault ?

  9. #9
    Moderator
    Join Date
    Aug 2007
    Location
    Germany
    Posts
    855
    Version
    IrfanView 4.51
    OS
    64-bit Win 10
    CPU Cores
    8

    Default

    Hi,

    did you change anything? The path and file types should be no problem...
    I can not find a "gt" in the script...

    Oder auf Deutsch:
    hast Du etwas geändert? Also außer den Pfaden und Dateitypen?
    Ein "gt" finde ich nicht...

    Regards
    Nils

  10. #10
    IV Beginner
    Join Date
    Aug 2011
    Posts
    57
    Version
    IrfanView 4.38
    OS
    64-bit Win 7 Professional SP1
    CPU Cores
    8

    Default

    Quote Originally Posted by derniwi View Post
    Hi,

    did you change anything? The path and file types should be no problem...
    I can not find a "gt" in the script...

    Oder auf Deutsch:
    hast Du etwas geändert? Also außer den Pfaden und Dateitypen?
    Ein "gt" finde ich nicht...

    Regards
    Nils
    Hier -->

    Click image for larger version. 

Name:	_PrintLoop-error-gt-1.jpg 
Views:	245 
Size:	130.0 KB 
ID:	4195
    Last edited by Marti; 22.09.2015 at 11:24 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •