Announcement

Collapse
No announcement yet.

Batch files and Scripts

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Sorry. I am giving you the wrong information here. The Command prompt window should not close when the operation is complete. It should just display another prompt.

    I just tried a big multiple file /advancedbatch operation like the one being discussed and the new prompt appeared after a very short delay. The Irfanview operation went on for several minutes before completion but the Command prompt window remained open even after it was all finished.

    On the other hand the window for a batch file doing the same job remained open until Irfanview had completed the whole task and then closed. I had to include a Pause line to keep it open after Irfanview had finished.

    Comment


      #17
      Batch Batch?

      I would like to use IrfanView to convert files in various directories. Can I use a batch script for this? It might contain lines like this:

      IrfanView convert D:\Folder1\File1.jpg to be D:\Folder2\File1.pdf
      IrfanView convert D:\Folder3\File1.pdf to be E:\Folder7\Filex.bmp

      I would have located my source files by running DIR File*.* /s > FileList.txt at the D:\ prompt. I would then alter the lines in FileList.txt to produce FileList.bat, with lines like those shown above.

      Comment


        #18
        Yes. You will find the Command line options in the Overview chapter of the Irfanview help file. Read the examples for Conversion to see the format for command lines that you can put into a batch script. Were you thinking of creating a long batch file with a separate command line for each conversion you want or are you aiming for the batch file to read each path and filename from the text file as it does the conversions?

        Comment


          #19
          Sending key strokes to Irfanview

          There are many actions that are possible in the Irfanview GUI but not from a Command line option. In that case it may be necessary to send keystrokes to Irfanview from outside the program. So I thought I would just record here how I do that using a Visual Basic script (VBS).
          VBS runs under Wscript.exe and it is necessary to first create a Wscript shell object to use its sendkeys function. In the VBS script below the keys Alt+i, f and b are sent to produce the Blur effect. Since a second dialog is opened after the f is sent a 100msec delay has been put in before sending the b. This may not be needed but does illustrate how it is done if necessary.
          Code:
          Set Shell=WScript.CreateObject("WScript.Shell")
          Shell.Sendkeys "%if"
          Wscript.Sleep 100
          Shell.Sendkeys "b"
          Set Shell = Nothing
          This works fine if the Irfanview window was opened from the script since the focus is in that window and the key strokes are sent to the right place. If the VBS script is to be started from a shortcut after the Irfanview window has been opened though, the action of starting the script will have moved the focus away from Irfanview. The focus then needs to be switched back to Irfanview before sending the keystrokes. This presents a problem because it is necessary to know the name of the application window and Irfanview creates a complex name such as "image1.jpg - Irfanview (Zoom: 1100 x 820)" so that it can be displayed in the Caption bar above the image.
          If you have a program like Microsoft Word installed you can borrow its ability to supply the names of all the application windows currently running on the computer and search for one that contains the word "Irfanview" in it, and that is what I have done in the script below which sends the keys e, Alt+g and Esc to automatically open Google Earth to show the GPS position recorded in the Exif data.
          Code:
          Set Shell=WScript.CreateObject("WScript.Shell")
          Set Word = CreateObject("Word.Application")
          Set Tasks = Word.Tasks
          For Each Task in Tasks
           If Task.Visible And instr(Task.name, "IrfanView") >0 then Shell.AppActivate Task.name : Exit for
          Next
          Wscript.Sleep 10
          Shell.Sendkeys "e%g{esc}"
          Set Shell = Nothing
          Word.Quit
          As usual just copy and paste the code into Notepad and Save as, for example, "Google_earth.vbs" making sure that you select "All files" from the drop down so that Notepad does not automatically add ".txt" to it.
          I made Google_earth.vbs my second External editor and could then call it (from Irfanview v4.30) by pressing the hotkey Shift+2. You could equally well call it from a desktop shortcut that uses a hotkey as long as it does not conflict with any in Irfanview.

          Here is a link to information about the Windows Script Host Sendkeys function.
          Last edited by Mij; 29.09.2011, 08:44 PM. Reason: Added link at bottom.

          Comment

          Working...
          X