i need a script that notify's me about document's file type

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

Rub

i need a script that notify's me about document's file type

Post by Rub »

i'm hell good at actions but i don't know any prog language, that's why i need help.
i'm using Photoshop CS on Windows 2K platform, and i need a JavaScript script that loads at Photoshop start and will notify me when I open a document in an other file format than JPEG (jpg,jpeg)

eg. when i open a tiff or gif, an error message will popup and say: "Pay attention! This is not a JPEG file!"


for any help u can give please write back here or at adrian.dogar@informmedia.ro

thanks in advance
best regards,
rubby
Andrew

i need a script that notify's me about document's file type

Post by Andrew »

Welcome Rubby

We'll see if anyone else comes up with a suggestion but I would say that is something that cannot be done with javascript. PSJS basically takes control from / of PS, does various things including receiving input from the user, finishes it's task and hands control back to PS.

So while the JS is running you can't go and do other things in PS as far as I know.

Andrew

PS Thinking about this a bit more, I guess you might be able to use a script whose sole task is to open documents (from the File Browser for example). It could be run from an action via a Fn Key. So, you select an image in the FB, hit the Fn Key, the script checks the image type and issues a warning if necessary, then opens the image. I can see this getting messy however if you want to run through a series of images one at a time as the script has to end after opening each image (or open all the images in one go and then end).

Another angle is that scripts are very effective at organising images into folders - so you could have a script that looks at a target folder, creates an 'other' subfolder and moves all your non-jpg images into that folder. It could even create a different folder for each image type.
xbytor

i need a script that notify's me about document's file type

Post by xbytor »

If you want some javascript code to execute a whenever a document is opened, you need to use PSCS2. It has added a new Notifier class that lets you associate code with various events.

Check the CS2 scripting docs here for details.
Larry Ligon

i need a script that notify's me about document's file type

Post by Larry Ligon »

Rubby,
1. Fist script must warn me when i want to open „save” or „save as” dialog that my active picture is not in CMYK mode (we work for newspapers and the printings are made in CMYK) and this error message should have 2 buttons: yes and no, yes will put the picture in CMYK mode and continue with saveing and „No” button will let me save it as it is .. in other color mode. (for an ideea i have a small script that works for me with that, but it says that is not CMYK only after i saved it. I want to warn me before save. I will attache this script.)
Here is one way to do this:
Open up Notepad and cut and paste this code and save the file as
"Save CMYK files.js" in the folder "C:\Program Files\Adobe\Photoshop CS\Presets\Scripts" as a text only file.

Code: Select all if (documents.length > 0)
 { if (activeDocument.mode != DocumentMode.CMYK)
    {
      var answer = confirm("Document is not CMYK\nDo you want to change to CMYK?");
      if (answer)
       {
       activeDocument.changeMode( ChangeMode.CMYK);
       };
    };
   
 // Tell Photoshopto display any dialogs.
 displayDialogs = DialogModes.ALL;
  app.activeDocument.saveAs( new File("~+app.activeDocument.name"));
 } else
    { // Gives this message if you don't have a document open in Photoshop.
     alert("You must have at least one open document to run this script!");
};
You can assign a function key to this script. Open up Photoshop CS. Select "Edit>Keyboard Shortcuts".
A dialog will open. Click on the arrow in front of "File" to expand it.
Scroll down until you see "Scripts>". Go to the script "Save CMYK files".
Click on that script. You can then hit a function key and that will be placed in the box to the right of the script.
An "Accept" button will appear to accept the assignment of that function key to this script. Hit the "Accept" button.

Now when you want to save CMYK files press the function key and a dialog will open up and you can save in any Photoshop format.

2. Second script must warn me when i open a picture in other format than JPEG (jpg and jpeg) that the picture is not a jpeg. Eg. when i load a .tiff picture an error message will popup and say „pay attention, this document is not a JPEG! ”
Here is one way to do this.

Open up Notepad and cut and paste this code and save the file as
"Open only JPG files.js" in the folder "C:\Program Files\Adobe\Photoshop CS\Presets\Scripts" as a text only file.

Code: Select allvar f = File.openDialog("JPG or JPEG File","JPEG or JPG:*.jpg;*.jpeg");
open(f);

You can assign a function key to this script. Open up Photoshop CS. Select "Edit>Keyboard Shortcuts".
A dialog will open. Click on the arrow in front of "File" to expand it.
Scroll down until you see "Scripts>". Go to the script "Open only JPG files".
Click on that script. You can then hit a function key and that will be placed in the box to the right of the script.
An "Accept" button will appear to accept the assignment of that function key to this script. Hit the "Accept" button.

Now when you only want to open up jpg files press the function key and a dialog will open up showing only *.jpg or *.jpeg files. You can then select one and then select open. The file will be opened in Photoshop.

Hope this helps,
LarryCode: Select all
Guest

i need a script that notify's me about document's file type

Post by Guest »

This is quite possible in PSCS2. They have scriptable events such as file open.
xbytor

i need a script that notify's me about document's file type

Post by xbytor »

Code: Select all//
// JpegCheck.jsx
//
// This file should be registered with the Open Document Event
//

var doc = app.activeDocument;
if (doc.name.match(/\.jpe?g$/i) == null) {
  alert("WARNING: The document '" + doc.name + "' is not a JPEG file");
}


Not quite sure about the 'e?' part in the regexp. Haven't tested it yet. But the rest has been tested and works on CS2.