Created
May 18, 2011 09:15
-
-
Save milligramme/978260 to your computer and use it in GitHub Desktop.
for InDesign, Sort printer presets in ascending or descending order
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sorting Printer Preset | |
*/ | |
$.localize = true; | |
if (!confirm({ | |
ja:"Alert!\nプリントプリセットを並べ替えをします。\n実行しない場合は「いいえ」", | |
en:"Alert!\nSort order of Printer Presets\nClick \"No\" to cancel" | |
},{noAsDefault:true} )) {exit();}; | |
var _sort = confirm({ | |
ja:"Order?\n昇順ソート : 「はい」, \n降順ソート : 「いいえ」", | |
en:"Order?\nAcsending Order : YES, \nDescending Order : NO", | |
}); | |
var dx = _sort === true ? 'a > b' : 'b > a'; | |
var pp = app.printerPresets; | |
// initialize | |
// for (var j = pp.length - 1; j >= 1; j--){ | |
// pp[j].remove(); | |
// }; | |
// sample data | |
// var pp_name = "東京 熱海 三島 名古屋 新尾道 京都 大阪 神戸".split(" "); // unicode | |
// var pp_name = "1 2 3 5 12 43 8 11".split(" "); // string | |
// var pp_name = "Tom Alice Jack Bruce Hellen Mick Bob Gui".split(" "); // string | |
// for (var k=0; k < pp_name.length; k++) { | |
// pp.add({name:pp_name[k]}); | |
// }; | |
var sorted_array = pp.everyItem().name.sort(function(a,b){return eval(dx)}); | |
for (var i=0; i < sorted_array.length; i++) { | |
if (sorted_array[i] == "[デフォルト]" || sorted_array[i] == "[Default]") {continue}; | |
var dup = pp.item(sorted_array[i]).duplicate(); | |
pp.item(sorted_array[i]).remove(); | |
dup.name = sorted_array[i]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment