open all file

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, Kukurykus, Tom

studiopayal
Posts: 2
Joined: Sat Mar 03, 2018 5:32 pm

open all file

Post by studiopayal »

first sorry my bad english
i have one 100 file in folder
file name is 1.2.3to 100
my scripts is

var inputFolder = Folder ( '~/Desktop/PAYAL_CREATION/File_100/' );
var fileList = inputFolder.getFiles( /\.(jpg|jpeg)$/i );
for ( var i = 0; i < fileList.length; i++ ) {
open (fileList);
};

but File open is 1,10,11,100,12,13 not 1,2,3,4,5...
please help me

User avatar
Dormeur74
Posts: 32
Joined: Mon Oct 03, 2016 4:56 am

Re: open all file

Post by Dormeur74 »

You are lucky, my English is worse than yours. But I hope you will understand me 8 months later..
You cannot work with an alphanumeric order. I propose to create a second table to sort the first in ascending order of values.
Exemple :

Code: Select all

/*************************************************************************************
*                        Michel Rohan (Annecy - France) 2016                         *
*                                                                                    *
*************************************************************************************/

#target photoshop 					// MAC Finder ou WINDOWS Explorer (double click)
app.bringToFront(); 				// Brings the application to the front
displayDialogs = DialogModes.NO;    // Disables dialog boxes

var inputFolder = Folder.selectDialog("Select the folder where your photos are : ");
var array1 = new Array();
var array2 = new Array();
var nbr = 100; // Or more
var mini = nbr + 1;
var id = 0;
	
var fileList = inputFolder.getFiles(/\.(jpg|jpeg|tif|psd|bmp|png|gif|pdf|)$/i);
for (var i=0;i<nbr;i++){
	var docRef = fileList[i].name;
	array1[i] = docRef.substring( 0, docRef.indexOf('.') );
}

for (i=0;i<nbr;i++) {
	mini = 101;
	for (var j = 0;j < nbr;j++) {
		if (Number(array1[j]) < mini) {
			mini = Number(array1[j]);
			id = j;
		}
	}	
	array2[i] = File(inputFolder+ "/" + mini+".jpg");
	array1[id] = 101;
}

for (i=0;i<nbr;i++) {
	// Your treatment
	//open(array2[i]) for instance
}