database problem

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: Tom, Kukurykus

illusion3k

database problem

Post by illusion3k »

Hello everybody,

I'm new in scripting and wanna ask for some help.

I wanna do a script to select an image (or use the active.Document > e.g. template.jpg) in photoshop. Then I wanna apply an action (e.g. change contrast & resize). After this I wanna use a simple .txt database (must be a selectable txt-file) as basic for the filenames (e.g. bubu1.jpg, bubu15.jpg, freak.jpg). The goal ist to select an image, apply an action and save this image with different filenames.

Is there any possibility to do this?


Here is a example of a txt-file...
Code: Select allbubu1,bubu15,freak

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

illusion3k

database problem

Post by illusion3k »

After searching, reading, testing and coding a couple of hours, I'm one step closer...

Code: Select all#target photoshop
app.bringToFront();

if(app.documents.length > 0){
    myFunction();
}else{

if(isWindows()) var fileMask = '*.jpg';
if(isMac()) var fileMask = function(file){file.name.match(/\.jpg$/i) ? true:false;}
var myFile = File.openDialog ('Select image', fileMask, true);

function isMac() {
if ( $.os.search(/macintosh/i) != -1 ) {
return true;
} else {
return false;
}
};
function isWindows() {
if ( $.os.search(/windows/i) != -1 ) {
return true;
} else {
return false;
}
};
}
if(myFile != null) app.open(myFile[0]);

try {
     app.doAction( 'Resize' , 'OWN');
}
catch( e ) { }


function myFunction(){

try {
     app.doAction( 'Resize' , 'OWN' );
}
catch( e ) { }

}

I know there are still a few bugs, but it'll work for me...

My biggest problem is to save the image with the different filenames from the txt-File. How can I do that, please? Any hints or examples?

Would be nice if somebody could help me...
bdeshazer

database problem

Post by bdeshazer »

So you're wanting to save multiple copies of the one file you opened and ran the action on, each with a different name that was read from the text file which is in CSV format?
illusion3k

database problem

Post by illusion3k »

Yes, that's what I want - except that the files extension was .txt and not .csv...
bdeshazer

database problem

Post by bdeshazer »

illusion3k wrote:Yes, that's what I want - except that the files extension was .txt and not .csv...

I meant that your "database" text file format was a comma-separated-value list...

So what exactly are you needing help with? It looks like you have the parts that will open a file and run your action, the remaining steps seem to be:

Open and read contents of txt file
Loop to save image out with different file name (what file format)
illusion3k

database problem

Post by illusion3k »

Thanks for your reply...

Perhaps I should mention that I am 46 years old and english isn't my preferred language. And the fact that this is my first attempt at scripting didn't makes it easier.

In theory, I know how the script must be built, but in JavaScript???

However I think it's easier for me to do it by hand as in the past.

Anyway thanks for the help.