Updated the old script with IF/ELSE/WHILE. Just change the path to Irfanview exe and you are good to go.
Code: Select all
//IrfanViewScript - version 3
// Needs atleast XYplorer version 8.60
"_assert : _assert"
$minimum = "8.60.0000"; $compatible = (compare(<xyver>, $minimum, v) == -1) ? 0 : 1; assert ($compatible), "XY too old! Continue at your own risk", 1;
global $g_IrfanPath;
//!!!IMPORTANT!!!
//Set the Irfanview file path below
$g_IrfanPath="c:\Program Files (x86)\IrfanView\i_view32.exe";
"IrfanViewSuite v3|i_view32 /8 : IrfanView"
sub _assert;
load *, "IrfanView;readme;-;rotate;RotateR;RotateL;RotateV;RotateH;-;slideshow;slide;-;convert;con;-;resize;res;-;panorama;l2r;t2b;-;imageinfo;allinfo;Individualinfo;-;edit;can;"
"(Read Me) : readme"
sub _assert;
Text "!!!REMINDER!!!: Change the Irfanview path in the script. <br><br>What does this script do? <br><br>
1) ROTATE: <br> - Rotates selected images to 90, 180 and 270 degrees and also creates mirror image. <br> - You can choose to backup files before resizing, else they will be overwritten. <br><br>
2) SLIDESHOW: <br> - Displays a slideshow of selected or all images in a folder. <br> - You can control the slideshow speed. <br> - You can run a slideshow from search tab too. <br><br>
3) CONVERT: <br> - Converts selected images to another filetype. For example, from png, jpeg > gif. <br> - You can choose to backup files before resizing, else they will be overwritten.<br><br>
4) RESIZE: <br> - Resizes selected images to different size. <br> - Aspect ratio is preserved. For example if you type width as 300 and height as 2, then 2 is ignored. <br> - You can choose to backup files before resizing, else they will be overwritten.<br><br>
5) PANORAMA: <br> - Create a panorama, i.e. joins selected images next to each other. <br> - You have the option to create vertical (top-to-bottom) or horizontal (left-to-right) panorama<br> - Original files will not be altered <br><br>
6) IMAGEINFO: <br> - Writes image info to a text file. <br> - You have two options: Write all image info to one text file or write selected image info to their respective text files. <br> - Sorry, info for selected files cannot be written to one text file.", 600,650, Info about IrfanViewSuite v3, w;
"-"
/*ROTATE SCRIPTS: START*/
"&1. ROTATE|i_view32 /1 : rotate"
sub _assert;
load *, "rotate;-;RotateR;RotateL;RotateV;RotateH;-;_back;can;"
" - Right : RotateR"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count==0){
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
}
IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
sel 1;
}
ELSE {
focus;
input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
backupto "$backup";
sel 1;
}
$curpos = 0;
WHILE ($count > $curpos){
$curpos = getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
sel +1;
}
filter;
status "Rotation finished";
focus c;
" - Left : RotateL"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count==0){
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
}
IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
sel 1;
}
ELSE {
focus;
input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
backupto "$backup";
sel 1;
}
$curpos = 0;
WHILE ($count > $curpos){
$curpos = getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /rotate_l /convert <curitem> /killmesoftly",,1;
sel +1;
}
filter;
status "Rotation finished";
focus c;
" - Upside-Down : RotateV"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count==0){
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
}
IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
sel 1;
}
ELSE {
focus;
input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
backupto "$backup";
sel 1;
}
$curpos = 0;
WHILE ($count > $curpos){
$curpos = getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
run """$g_IrfanPath""<curitem> /rotate_r /convert <curitem> /killmesoftly",,1;
sel +1;
}
filter;
status "Rotation finished";
focus c;
" - Mirror-Image (JPG Only) : RotateH"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count==0){
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
}
IF (confirm("Click 'OK' to overwrite current files or 'Cancel' to backup files")==1) {
sel 1;
}
ELSE {
focus;
input $backup, "Backup files to <curpath>\originals (or change below)", "<curpath>\originals";
backupto "$backup";
sel 1;
}
$curpos = 0;
WHILE ($count > $curpos){
$curpos = getinfo ("FocusedPos");
run """$g_IrfanPath"" <curitem> /jpg_rotate=(2,1) /killmesoftly",,1;
sel +1;
}
filter;
status "Rotation finished";
focus c;
/*ROTATE SCRIPTS : END*/
"-"
/*SLIDESHOW SCRIPTS : START*/
"&2. SLIDESHOW|i_view32 /1 : slideshow"
sub _assert;
load *, "slideshow;-;slide;-;_back;can;"
"- Slideshow : slide"
sub _assert;
global $g_IrfanPath;
focus;
$count= getinfo("CountSelected");
IF ($count == 0) {
getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files\IrfanView\i_view32.ini";
run """$g_IrfanPath""/slideshow=<curpath> /closeslideshow";
}
ELSE {
focus;
$count= getinfo("CountSelected");
#101;
#219;
set $slideshowtext, <curitem>;
getkey $irfdelay, "AutoDelay", "slideshow", "C:\Program Files (x86)\IrfanView\i_view32.ini";
input $userdelay, "Set slideshow delay (in seconds)", $irfdelay;
setkey $userdelay, "AutoDelay", "slideshow", "C:\Program Files (x86)\IrfanView\i_view32.ini";
run """$g_IrfanPath""/slideshow=$slideshowtext /closeslideshow ",,1;
Status "End of Slideshow";
delete /*No recycle bin*/0, /*Prompt before delete*/0, $slideshowtext;
}
/*SLIDESHOW SCRIPTS : END*/
"-"
/*CONVERT SCRIPTS : START*/
"&3. CONVERT|i_view32 /2 : convert"
sub _assert;
load *, "convert;-;con;-;_back;can;"
"- Convert images : con"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count == 0) {
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
input $ext, "Convert files to which extension? (Current files will not be overwritten)", gif;
sel 1;
$curpos=0;
WHILE ($count > $curpos) {
$curpos= getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /convert=<curpath>\<curbase>.$ext",,1;
sel +1;
}
}
filter;
status "Conversion finished"
/*CONVERT SCRIPTS : END*/
"-"
/*RESIZE SCRIPTS : START*/
"&4. RESIZE|i_view32 /2 : resize"
sub _assert;
load *, "resize;-;res;-;_back;can;"
"- Resize images : res"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count == 0) {
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
focus;
input $backup, "Before resizing original files will be backed up to <curpath>\originals (you can change this below)", "<curpath>\originals";
backupto "<curpath>\originals";
input $dimensions, "Convert files to what dimensions (width, height)? (Current files will not be overwritten)", "(300 ,300)";
sel 1;
$curpos=0;
WHILE ($count > $curpos) {
$curpos = getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /resize=$dimensions /aspectratio /resample /convert <curitem> /killmesoftly",,1;
sel +1;
}
}
filter;
status "Conversion finished"
/*RESIZE SCRIPTS : END*/
"-"
/*PANORAMA SCRIPTS : START*/
"&5. PANORAMA|i_view32 /1 : panorama"
sub _assert;
load *, "panorama;-;l2r;t2b;-;_back;can;"
" - Left-to-Right : l2r"
sub _assert;
global $g_IrfanPath;
focus;
$count= getinfo("CountSelected");
IF ($count == 0) {
sub "_unselected";
}
ELSEIF ($count == 1) {
status "Select atleast two files", ,alert;
end 1==1, "Cannot create panorama with one file. <crlf>Select atleast two files";
}
ELSE {
$selected=getinfo("SelectedItemsPathNames", ",");
substr $selected, $selected, 0,-1;
run """$g_IrfanPath"" /panorama=(1,$selected) /convert ""<curpath>\panorama.jpg"" /silent",,1;
Status "panorama.jpg created!";
}
" - Top-to-Bottom : t2b"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count == 0) {
sub "_unselected";
}
ELSEIF ($count == 1) {
status "Select atleast two files", ,alert;
end 1==1, "Cannot create panorama with one file. <crlf>Select atleast two files";
}
ELSE {
$selected=getinfo("SelectedItemsPathNames", ",");
run """$g_IrfanPath"" /panorama=(2,$selected) /convert ""<curpath>\panorama.jpg"" /silent",,1;
Status "panorama.jpg created!";
}
/*PANORAMA SCRIPTS : END*/
"-"
/*IMAGEINFO SCRIPTS : START*/
"&6. IMAGE INFO|i_view32 /1 : imageinfo"
sub _assert;
load *, "imageinfo;-;allinfo;Individualinfo;-;_back;can;"
" - All : allinfo"
sub _assert;
global $g_IrfanPath;
run """$g_IrfanPath""<curpath>\*.* /info=""<curpath>\ImageInfo.txt"" /silent /killmesoftly",,1;
" - Individual : Individualinfo"
sub _assert;
global $g_IrfanPath;
$count= getinfo("CountSelected");
IF ($count == 0) {
sub "_unselected";
}
ELSE {
$selected=getinfo("SelectedItemsNames", "|");
filter "$selected";
sel 1;
$curpos=0;
WHILE ($count > $curpos){
$curpos= getinfo ("FocusedPos");
run """$g_IrfanPath""<curitem> /info=<curpath>\<curbase>.txt /killmesoftly",,1;
sel +1;
}
}
filter;
status "Info ready"
/*IMAGEINFO SCRIPTS : END*/
"-"
"Edit script|:udc : edit"
self $ScriptFile, file;
Open $ScriptFile,w
"Cancel|:stop : can"
"_Unselected : _unselected"
status "Select atleast one file", ,alert;
end 1==1, "No files selected";
"Back|:back : _back"
load *, "IrfanView;readme;-;rotate;RotateR;RotateL;RotateV;RotateH;-;slideshow;slide;-;convert;con;-;resize;res;-;panorama;l2r;t2b;-;imageinfo;allinfo;Individualinfo;-;edit;can;"