Umenu autopopulate – always alphabetical order?

Jun 27, 2011 at 1:35pm

Umenu autopopulate – always alphabetical order?

Is there any way to autopopulate in order of date created?

#55308
Jun 27, 2011 at 11:13pm

If you put this JavaScript code into a [js] and send it the message “read path/to/the/folder” it will output all files by date modified/created ascending.

function read(path) {
	var folder = new Folder(path);
	var allFiles = new Array();
	var i = 0;
	 while (!folder.end) {
	 var d = new Date(
			folder.moddate[0],
			folder.moddate[1],
			folder.moddate[2],
			folder.moddate[3],
			folder.moddate[4],
			folder.moddate[5],
			0);
                // sort out hidden files and folders
                // and write others into an array
		if (folder.filename && folder.filetype!="fold") {
			allFiles[i] = {name: folder.filename, date : Number(d)};
			i++;

		}
		folder.next();
	 }
         folder.close();
         // sort the array by date asc
	 allFiles.sort(
		function(a, b){
			return a.date-b.date;
		}
	);
        // and finally send the file names to outlet
	for(var j=0;j

If you want to change the order to descending change the line:
"return a.date-b.date;"

into:
"return b.date-a.date;"

jan

#199068
Jun 28, 2011 at 7:43am

Wow – thank you so much for sharing this.

Awesome!

#199069
Jun 28, 2011 at 8:10am

;) !

#199070

You must be logged in to reply to this topic.