Announcement

Collapse
No announcement yet.

Launching Irfanview from a script file icon

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Launching Irfanview from a script file icon

    Note: I have edited this post because, from Irfanview v4.40, the feature provided by the script file below has been incorporated into the program itself. I have added it as item 4 of what you can now do with an Irfanview shortcut. Although it means that nobody is going to need this script again, the same limitations apply to the feature in Irfanview v4.40 as in version 1.1 of this script. What a good job I am up to version 1.8. Irfanview still has a long way to go to catch up.
    So do read the introduction below to discover what this is all about, but you will probably then want to skip on to v2 of the script in the second post of this thread.

    Four things you can do with a shortcut to Irfanview are

    1. Double click on it, then use File>Open to select and display the image.
    2. Drag a single image file from Windows Explorer and drop it onto the shortcut.
    3. Drag a folder containing image files from Windows Explorer and drop it onto the shortcut.
    4. (New) Drag more than one image file from Windows Explorer and drop them onto the shortcut.

    In each of methods 1 to 3 above, one file is opened and displayed, but Irfanview also prepares a browse list of all the other image files in the folder so that they can be displayed by using the arrow icons or keys. Before listing the files are filtered to check that file types are only those chosen in the Associations tab of Options/Properties and then sorted into the order specified in Options>Sort directory files. The first image is not displayed until all the filtering and sorting is complete.

    Annoyances reported by users are
    a. Big folders containing a very large number of files can take a long time before the first image is seen.
    b. The order of the files as they were shown in Windows Explorer is changed, even if No Sort is requested.
    c. Only real folders are supported. Virtual folders that Windows Explorer can show such as Libraries or Search results cannot be used.

    These are now all possible in IV v4.40 using method 4 above which behaves exactly as the script described below does.

    This Visual Basic script file is intended to be used as an Irfanview shortcut. It behaves just like a standard Irfanview shortcut for cases 1 to 3 but will also accept a random set of files selected from any real or virtual Windows Explorer folder and dragged onto it. It builds the selected file names into a list and then launches Irfanview using the /filelist=txtfile Command line option. You no longer need to have the whole folder in the Browse list and the order of the files can be kept as they were in the Explorer window.

    This code can be copied and pasted into Notepad. Edit line 1, if you need to specify a different location for the Irfanview exe file, and then Save it as a .vbs file. A readme.txt file is attached below the listing with a bit more information.

    Code:
    THE CODE HAS BEEN MOVED TO THE README.TXT FILE
    TO PREVENT IT FROM BEING CORRUPTED
    Attached Files
    Last edited by Mij; 23.06.2016, 09:42 PM. Reason: See first paragraph. Code moved to Readme file

    #2
    Version 2 of this script

    Having used this script as a shortcut to Irfanview for several months now, I am quite pleased with it but have seen several ways of making it better. I found it a bit frustrating not to have the filter that Irfanview normally applies to prevent file types that it cannot open from getting into the browse list. Whenever you do browse to such a file Irfanview stops with an Error message that has to be cancelled before you can proceed again. The Thumbs.db file that Windows 7 places into every folder is a frequent culprit. So the new version of the script listed below now includes a filter to address this issue.

    Another thing I often wanted to do was to add more files from the same or a different folder to the browse list after Irfanview had been opened. So with this new version you can open Irfanview by dragging a group of 2 or more files from a folder and dropping them onto the shortcut and then you can drop another group from the same or another folder onto the shortcut. I could not find a way to add more files to an existing Irfanview window, so the program closes the existing one and opens a new window with all the files now in the browse list.

    It is now also possible to open a file list that has been saved previously as a text file from the slideshow dialog or elsewhere. A single drag and dropped file with a .txt extension is now treated as a file list and the image files listed in it are placed in the Browse list in the order they occur in the text file.

    If you want to just try out the script open the Readme2.txt file and follow the instructions to save as a vbs file on the desktop. Double click on the file icon on the desktop and either an empty Irfanview window will open or an error message box will appear to notify you that your copy of the Irfanview executable file i_view32.exe cannot be found at the default location. Instructions on how to edit the file to correct this are also in the Readme2.txt file. Then just drag a bunch of files from an image folder opened in Windows Explorer onto the vbs file icon and see what happens. The Readme.txt file also explains how a desktop shortcut to Irfanview can be created so that files for opening can be dropped there instead of directly onto the vbs file and also how to edit the filter and possibly the location of the temporary file in which the list is built up.

    Code:
    THE CODE HAS BEEN MOVED TO THE README2.TXT FILE
    TO PREVENT IT BEING CORRUPTED
    Attached Files
    Last edited by Mij; 23.06.2016, 10:11 PM. Reason: Simplified to avoid duplicating post 1 and extended with new feature details. Code moved to Readme2.txt

    Comment


      #3
      It occurred to me that instead of telling people how they can edit the script file to find the Irfanview run time file and how to create a desktop shortcut to use with it, I could let the script do both of those for you. So this is the version that does just that.

      I have attached a text file with instructions of where to put the script file and how to use it. Just download it and double click to open it in the default text viewer.
      The script is also attached as a text file. No zip files to open this time. Download that, read it, copy it or whatever you want. It contains comments that might help you to understand it if you already know a bit about Visual Basic Scripts, but no matter if you don't. You can save it with a new name and/or extension and then just use it as it is.

      It is particularly useful for running portable copies of Irfanview from a USB stick. You do not need to edit drive letters or even know what drive you are working with. Just click on "Open folder to view files" when Windows shows the dialog and locate the script file. Double click on it and you have a shortcut on the desktop of the host computer ready to use.
      You can drag and drop image files to that shortcut from your USB stick, another stick, a disk, the host computer itself. ... any number of files, any combination and any order. You never need to wrestle with whatever unfamiliar image viewer happens to be associated with the image file types on that computer. It is always your Irfanview that opens.

      The file that contains the list also appears on the desktop while you are using it and is deleted automatically when you close Irfanview. When you have finished using the computer just delete the shortcut from the desktop and nothing is left behind there.
      Attached Files

      Comment


        #4
        Hi All
        I have now been using the script I last posted for nearly a year with a group I belong to. I take along my USB memory stick with a very basic Irfanview installation on it and the launcher script. Other members bring along their sticks with images they want to talk about. I plug my stick into the computer where we meet (which doesn't have Irfanview installed), open Windows Explorer, find the script file on it and double click that.
        Irfanview opens an empty window and a Shortcut icon also appears on the Desktop. I have to leave my stick plugged in obviously to be able to run Irfanview but I can now close that Explorer window because it is not needed again.

        Someone else then plugs in their USB stick too and the files they want to show are just dragged and dropped onto the icon. One or more folders can be dropped on, or a block of files or a list of files. As soon as they are dropped Irfanview shows the first of them, with all the others lined up ready to be shown after it. More can still be dropped on if you want them. While the Irfanview window is open a temporary text file containing a full list of the files on display is available on the desktop. This can be copied to the stick and used another time to open the same show. When viewing of those images is finished, closing the Irfanview window causes the temporary list to be deleted, ready for another to be started if required.

        The only problems we have encountered are with file lists that are saved as above or that members sometimes prepare at home to specify the order in which images are to be shown. The drive letter that the computer assigns to the USB stick can change according to how many sticks are plugged in, so the file path in the list is often incorrect. To deal with that I have written a small subroutine to correct the errors automatically and that is now in the script. For it to work the file list must be located on the same USB stick as the images. If the list is in the same folder as the images it will even cope when the folder is moved to a new location. I have also added an option box that appears when you double click the icon again. This gives an option to close down everything and delete the shortcut icon from the desktop when you are finished , leaving nothing behind on the computer.

        Because the shortcut acts very much like a bucket that you just drop all the files you want into, I decided to call it "Irfanview bucket" and made a suitable icon for it. I now just have one simple folder named Irfanview on my stick that contains "i_view32.exe", "i_view32.ini", "i_view32.ico" and "Irfanview bucket.vbs". That is all we need.

        I am posting the new script here first because it is a development of the previous posts. Along with the script, I have included another file called "Script Information.txt" that tells you how the script works in case you want to modify it or copy bits to use elsewhere. Because of the limitations of the forum on the file types I can post, the Script is attached as "Irfanview bucket.txt" which needs to be renamed to "Irfanview bucket.vbs" to use it, and the icon as "i_view32.gif" which needs to be opened in Irfanview and saved as "i_view32.ico" with the white background selected as transparent.

        I intend soon to start a thread in the Technical section on "Using a portable version of Irfanview on a USB stick" and will include this script with it, probably as a Zip file that contains the whole package. Any comments before I do would be welcomed.

        Because of errors that appearing in the Script when placed in a code box this is no longer displayed.

        The script file (Irfanview bucket) and information are attached as text files (.TXT) below. Please download to read them.
        The icon is attached as a GIF image file
        Attached Files
        Last edited by Mij; 21.01.2015, 09:23 PM. Reason: Updated to v1.7. Code box no longer displayed

        Comment


          #5
          wish and bug

          Thanks you for this famous script.
          On big folders I get a error in this line:
          " If IsWanted(strFile,strImages) then f1.WriteLine(strFile)"

          I think there is a little bug. When I add a empty Folder, then the complete list is reseted.

          Is it possible to add a option for searching the sub-folders to,
          or can you tell what I must add (and where)?

          My System: Windows 7, 64 bit, Irfanview 4.40 64 bit.

          Thank you
          Marti

          Comment


            #6
            We established by private message that the bug appears to be caused by a star character in the name of one file. A slightly odd problem since Irfanview accepts the character with some settings in the ini file but not with others. I have not put any "OnError Resume Next" lines in the VB script code to trap errors because the problems are then ignored. I prefer to let the shell program trap the errors and give error messages that can be investigated.

            If you are working with big folders though it is worth noting that there is a known limitation on the number of individual files that can be transferred in one drop on the IV bucket icon, typically around 400 files. That is because in VBS the string containing the file paths and names that is dropped cannot exceed 32K characters in length. If you are dropping complete folders though, they can contain as many files as you like.

            I will look at including sub-folders as requested, but I am rather busy at present and cannot say when I will get around to it.

            Comment


              #7
              Sorry for the wait. Here is v1.8 of the script which will include the files in all the subfolders as well as those in the parent folder.

              You will see that I have moved the code that extracts file names from a folder, into a subroutine called unpack. After extracting the files the subroutine goes on to extract all the subfolders and calls unpack again for every one it finds. If there are subfolders in that the files are extracted from them using the unpack subroutine again, and so on until everything in that branch has been listed.

              Be warned though that it can take a while to extract everything. Script files run much slower than compiled programs do. On my computer it took about 10 seconds to list 1000 files and open them in Irfanview.

              If you do not want to extract from subroutines just edit the first line in the Setup section of the script to read "include_subs = False"
              As usual just rename the .txt file to .vbs to run it.
              Attached Files
              Last edited by Mij; 13.12.2015, 05:36 PM. Reason: Update to v1.81. Minor changes to Relocate subroutine to improve speed and scope

              Comment


                #8
                Thank you, works very nice with subfolders now.
                Great work

                For all others: You can put more differnent Folders on the bucket-icon, they all will be counted and on the thumbnails shown !
                for exampel: 100 in the Picture-folder and 50 in the subfolders and 200 in the download folder and 30 in the work-folder --> 380 pictures, tif, png ... are found and displayed.

                And you have a text file Buck_list.txt with all the selected files.

                Comment

                Working...
                X