Skip to main content
Vfxvenkat98
Known Participant
November 13, 2016
Question

Indexof file names.

  • November 13, 2016
  • 8 replies
  • 1684 views

Hi,

     I used to be open 100 images daily from different folders to Photoshop  but i don't want the files which are named as( .FC50, FC51, FC 60,) to be include in my workflow,

so i want to create a alert or popup to warn me this is a image which you no need to process and continue to next files.

For example my file names like :

12345.CBN014.FC50.jpg

12345.CBN016.FC51.jpg

1452345.CBN015.FC51.jpg

356345.CBN054.FC60.jpg

My basic idea was if i drag and drop the images into Photoshop with index of (.FC50,51,60.)  it should  show an warning or popup stating you no need to process and also move those files in a separate folder in active document location.

please help me in this ..

Thanks in advance

This topic has been closed for replies.

8 replies

Vfxvenkat98
Known Participant
November 21, 2016

Thanks a lot pixxxel schubser  and all I got solution. Thank u very much

Vfxvenkat98
Known Participant
November 20, 2016

yeah i understand but we can create an alert box using js like alert panel but confused part is to link with buttons

JavierAroche
Inspiring
November 20, 2016

HeyVfxvenkat98​, this ScriptUI guide by pkahrel​ is everything you need to know about UI scripting in ExtendScript.

https://indd.adobe.com/view/a0207571-ff5b-4bbf-a540-07079bd21d75

Also, do a quick search for questions / posts about Photoshop UI on this site or on google, there's plenty of information out there.

The initial question was answered a long time ago by pixxxel schubser​.

Vfxvenkat98
Known Participant
November 19, 2016

Thanks pixxel schubser the only problem now i am having is i need to add the close button on the alert box it is useful in future. but i got confused in buttons

pixxxelschubser
Community Expert
Community Expert
November 19, 2016

Now I'm really confused.

An alert always have a OK-Button and the little close "x" in the topright corner.

Furthermore: it is impossible to add a button on the alert box.

Vfxvenkat98
Known Participant
November 14, 2016

wow its working thanks a lot and just want to if we can add the close document command when clicking ok so that if incase FC images opened in photoshop a alert will popup to addon the close function will close the images in photoshop

pixxxelschubser
Community Expert
Community Expert
November 14, 2016

Vfxvenkat98 schrieb:

wow its working thanks a lot and just want to if we can add the close document command when clicking ok so that if incase FC images opened in photoshop a alert will popup to addon the close function will close the images in photoshop

Where is the problem?

Insert a close command after the alert.

//alertIfNamehasPartDotFCnumber.jsx

var Nm = activeDocument;

if (Nm.name.match(/\.FC(5[01]|60)/) == null) {

        alert ("nothing to do with  " + Nm.name + "\nThe document will be closed.");

        Nm.close();

        }

But this is IHMO a little bit senseless. See my previous posting:

Hmmh?

Why do you want open images which are alredy retouched? I given you a filter. This filter helps you to open only the images with (or without) the ".FCnumbernumber" part.

This is a very flexible method.

If you want works with opened files change line#1

  1. var Nm = Folder.selectDialog ().getFiles(/\.jpe?g$/i); 

  to

  1. var Nm = app.documents; 

Have fun

Hope, this will help you.

Vfxvenkat98
Known Participant
November 13, 2016

What i want is.

Step 1.open images into photoshop

Step 2.if the images are named with (.FC) it should throw an alert with this comment.("The image is already Retouched")

Step 3. IF the images are not named with (.FC) no alert would be displayed.

pixxxelschubser
Community Expert
Community Expert
November 13, 2016

Hmmh?

Why do you want open images which are alredy retouched? I given you a filter. This filter helps you to open only the images with (or without) the ".FCnumbernumber" part.

This is a very flexible method.

If you want works with opened files change line#1

var Nm = Folder.selectDialog ().getFiles(/\.jpe?g$/i);

to

var Nm = app.documents;

Have fun

Vfxvenkat98
Known Participant
November 13, 2016

I can understand but if it is possible with my idea the i can trigger the script with script events manager with open document events based so that i asked like this.

I hope you understand

Vfxvenkat98
Known Participant
November 13, 2016

i am not sure with (indexOf) function  does this work or not ?? and dont know how to trigger this script with based on Open document event.

pixxxelschubser
Community Expert
Community Expert
November 13, 2016

To much values for indexOf().

Please explain exactly what do you really want.

E.g. you can store the jpg files in one Folder in the (same Nm- ) array (like I show you before)

var Nm = Folder.selectDialog ().getFiles(/\.jpe?g$/i);

/*var Nm = [

"12345.CBN014.FC50.jpg",

"12345.CBN016.FC51.jpg",

"1452345.CBN015.FC51.jpg",

"356345.CBN054.FC60.jpg",

"356345.CBN054.FC61.jpg"

];*/

for (i=0; i<Nm.length; i++) {

    if (Nm.name.match(/\.FC(5[01]|60)/) == null) {

        alert ("do anything with Nm["+i+"] " + Nm); // result: do anything with Nm[4] 356345.CBN054.FC61.jpg

    }

}

Have fun

Vfxvenkat98
Known Participant
November 13, 2016

thanks pixxxel schubser,

But the image which i getting was named like that only so that's the reason for naming like that but in the above script lines you declared a variable with my exact file names but in different cases my file names are in different names what should do on that time ??

and also i need to move those images into seperate folder

pixxxelschubser
Community Expert
Community Expert
November 13, 2016

Hi Vfxvenkat98​,

<Off topic>

Please do never use additional dots in filenames.

<\Off topic>

You can work with a filter like:

var Nm = [

"12345.CBN014.FC50.jpg",

"12345.CBN016.FC51.jpg",

"1452345.CBN015.FC51.jpg",

"356345.CBN054.FC60.jpg",

"356345.CBN054.FC61.jpg"

];

for (i=0; i<Nm.length; i++) {

    if (Nm.match(/\.FC(5[01]|60)/) == null) {

        alert ("do anything with Nm["+i+"] " + Nm); // result: do anything with Nm[4] 356345.CBN054.FC61.jpg

    }

}

Have fun