admin wrote:Funny, but I had the same idea some days ago!
Are this qualified for the two fouls rule ?
Code: Select all
v9.50.0108 - 2010-09-27 15:22
+ Scripting got a new command.
Name: selectitems
Action: Selects items in the file list by a list of names.
Syntax: selectitems itemlist, [ignoreextensions], [focusfirst=1]
Improvement wish:
Add / Remove from the current selection:
Code: Select all
Syntax: selectitems itemlist, [ignoreextensions], [focusfirst=1], [variety=0]
variety : 0 or missing = instead of the current selection if any.
1 = Add to the current selection.
2 = Remove from the current selection.
- - -
Today i tested this improved script.
Now i am using an ini file
"<xydata>\Sessions\Selections.ini"
and tested new selectitems cmd:
EDIT: added code with new features from v9.50.0111
Code: Select all
/*
Script to store current selections and restore them later.
I use an ini file: "<xydata>\Sessions\Selections.ini"
v9.50.0108 - 2010-09-27 15:22
+ Scripting got a new command.
Name: selectitems
Action: Selects items in the file list by a list of names.
Syntax: selectitems itemlist, [ignoreextensions], [focusfirst=1]
v9.50.0111 - 2010-09-29 10:01
+ SC selectitems enhanced. Added a "mode" parameter which allows you
to add to or remove from current selections. Here is the complete
updated description:
Name: selectitems
Action: Selects items in the file list by a list of names.
Syntax: selectitems itemlist, [ignoreextensions], [focusfirst=1], [mode]
mode:
n: [Default] New selection (drop current selections).
a: Add the matches to any current selections.
r: Remove the matches from any current selections.
Example:
::selectitems "Canary.txt", , , "a"; //add to current selections
*/
"Store Selection : Store"
////////Store current selected items to an file:
self $ScriptFile, file;
$IniFolder = "<xydata>\Sessions"; IF (exists($IniFolder) != 2) {new $IniFolder, dir;}
$IniFile = "$IniFolder\Selections.ini";
$StoreName = Input("Unique Name for this selection:");
////Don't use []'s in $StoreNames:
if (strpos($StoreName, "[")>0 || strpos($StoreName, "]")>0)
{
msg "Please don't use '[' or ']' signs in an name.";
setting "AllowRecursion"; Load $ScriptFile, Store; break;
}
////getkey(key, [section], INIfile)
$CheckPresent = getkey("Items", $StoreName, $IniFile);
If ($CheckPresent != "")
{
////inputselect(header, listdata, [separator=|], [style=1], [cancel], [width], [height], [caption])
$Choice1 = "Use this name and overwrite previous items";
$Choice2 = "Let me enter an an alternative name";
$ASK = inputselect("This name already exist. Chose one of this choices:",
$Choice1|$Choice2 , , , "Canceled", 200, 100, "Upps");
If ($ASK==$Choice1){;}
If ($ASK==$Choice2){ setting "AllowRecursion"; Load $ScriptFile, Store; break; }
}
$SelItems = get("SelectedItemsNames", "|");
$SelCount = get("CountSelected");
////setkey value, key=, [section], INIfile;
setkey $SelItems, "Items", $StoreName, $IniFile;
setkey $SelCount, "Count", $StoreName, $IniFile;
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
"Load Selection : Load"
////////Load items to select from an file:
$IniFolder = "<xydata>\Sessions";
$IniFile = "$IniFolder\Selections.ini";
$Lines = readfile($IniFile);
////get all lines from $IniFile to select all section-names for the inputselect() list:
$Loop=1;
$Values="";
while(true)
{
$Line = gettoken($Lines, $Loop, "<crlf>");
if ($Line==""){break;}
if (substr($Line, 0, 1)=="[")
{
$Len = strpos($Line, "]") -1;
$Value = substr($Line, 1, $Len);
$ItemsCount = getkey("Count", $Value, $IniFile );
$Values = $Values . $Value . " ($ItemsCount Items)|";
}else{;
}
incr $Loop;
}
////ask user what to load:
$Setting1 = "[ Setting: Ignore the Extensions on selection ]";
$Setting2 = "[ Setting: Add the matches to any current selections ]";
$Setting3 = "[ Setting: Remove the matches from any current selections ]";
$Values = $Values$Setting1|$Setting2|$Setting3;
$Load = inputselect( "Choose one to restore an selection:", $Values,,2);
////If an setting is checked:
if ( strpos($Load, $Setting1) > 0)
{
$Load = replace($Load, "|$Setting1");
$IgnoreExtensions=1;
}
if ( strpos($Load, $Setting2) > 0 && strpos($Load, $Setting3) > 0)
{
msg "Please Choose Only One Of This Settings! (add OR remove) ";
setting "AllowRecursion";
self $ScriptFile, file;
Load $ScriptFile, Load; break;}
}
if ( strpos($Load, $Setting2) > 0)
{
$Load = replace($Load, "|$Setting2");
$SelectionMode="a"; //add items to selection
}
if ( strpos($Load, $Setting3) > 0)
{
$Load = replace($Load, "|$Setting3");
$SelectionMode="r"; //remove items from selection
}
////If more then one stored values are selected:
if ( strpos($Load, "|") > 0)
{
msg "Please Choose Only One Of The Stored Selections! ";
setting "AllowRecursion";
self $ScriptFile, file;
Load $ScriptFile, Load; break;
}
////clean the $Load string:
$Load = regexreplace($Load, "(.+)\s\(\d+\sitems\)", "$1");
////get the right line and select
////getkey(key, [section], INIfile)
$Selection = getkey("Items", $Load, $IniFile);
//selfilter $Selection; //old way
////selectitems itemlist, [ignoreextensions=0 , 1 = yes], [focusfirst=1], [mode]
selectitems $Selection, $IgnoreExtensions,,$SelectionMode;
///////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
"Edit this &script : edit"
self $ScriptFile, file;
OpenWith "<xypath>\Tools\NotePad2\Notepad2.exe", ,$ScriptFile;
//OpenWith "Notepad.exe", ,$ScriptFile;
////EOF
Unfortunately i have forgotten to add an Remove-Stored-Values feature...
So just open the ini file to add/modify/remove the entried:
"<xydata>\Sessions\Selections.ini"
[TEST Selection No. 47]
Items=DSC_12 34.PSD|DSC_12 34.XMP|DSC_12 345.PNG
Count=3
An preview how this will look:
