Tuesday, May 08, 2012

SkyDrive Arrange\Sort Photo by file name

How to sort photos in skydrive.live.com by file Name;

not sexycode, but... tested on Chrome 15;

The main idea is to collect all file names in one array, sort it. and then update image's index as in array;

To run this script you have to go to the Arrange page; and run script in address bar; be etentive some browsers could omit 'javascript:', may be for some security reasons. Or you can add this string to the Favorits, so the sorting will be more convenient. :)

direct order;
javascript:(function(){var f = jQuery.find('#appFrame');var j = jQuery(f);j.contents().find('.avImageThumb');var d = [];var a = j.contents().find('.avImageThumb');jQuery.each(a, function(i, l){var e = jQuery(l); d.push(e.attr('alt'));});d.sort();jQuery.each(a, function(i, l){var e = jQuery(l);var m = d.indexOf(e.attr('alt')) + 1; e.parent().parent().parent().next().find(':input').val(m); e.parent().parent().parent().next().find(':input').change(); });})();

revers order 
javascript:(function(){var f = jQuery.find('#appFrame');var j = jQuery(f);j.contents().find('.avImageThumb');var d = [];var a = j.contents().find('.avImageThumb');jQuery.each(a, function(i, l){var e = jQuery(l); d.push(e.attr('alt'));});d.sort();jQuery.each(a, function(i, l){var e = jQuery(l);var m = d.length - d.indexOf(e.attr('alt')) + 1; e.parent().parent().parent().next().find(':input').val(m); e.parent().parent().parent().next().find(':input').change(); });})();