Page 1 of 1

Sort Favorite Folders only below the last separator

Posted: 10 Jul 2009 18:00
by nf_xp
This script only sort Favorite Folders below the last separator, as the following illustration:
2009-7-10 23-37-42.jpg
Steps:
1. Create a script file named as SortFavorites.xys in your script folder:

Code: Select all

	#182; // Save All Settings

	getkey $count, "Count", "Favorites";

	// Find the last separator
	$last_separator = 0;
	$i = $count;
	while ($i > 0) {
		getkey $value, "Fav".$i, "Favorites";
		if ($value == "-") {
			$last_separator = $i;
			break;
		}
		$i--;
	}

	// Sort and write back to ini
	$i = $last_separator + 1;
	while ($i < $count) {
		getkey $vi, "Fav".$i, "Favorites";
		$min_index = $i;
		$min_value = $vi;
		$j = $min_index + 1;
		while ($j <= $count) {
			getkey $vj, "Fav".$j, "Favorites";
			if ($vj < $min_value) {
				$min_index = $j;
				$min_value = $vj;
			}
			$j++;
		}
		if ($min_index != $i) {
			setkey $min_value, "Fav".$i, "Favorites";
			setkey $vi, "Fav".$min_index, "Favorites";
		}
		$i++;
	}

	#190; // Restart without Saving
2. Added it to somewhere convenient, for example, User-defined commands, or in the Favorite Folder list!
2009-7-10 23-42-13.jpg
3. Use it!

There is a related XYplorer bug: http://www.xyplorer.com/xyfc/viewtopic.php?f=2&t=3830
Workaround: Call this script from non-context menu, for example, Favorite Folders sub-menu from main menu, or User-defined commands