Skip to main content
Participant
March 3, 2009
Question

Scripting novice needs help!

  • March 3, 2009
  • 3 replies
  • 692 views
Apologies in advance for asking a "how do I do this" question. While I've written a couple of very simple scripts in the past, it's been a couple of years, and I don't know where to begin with this one:

Somehow a couple of my files got damaged, such that when I try to open them Photoshop CS3 returns a dialog saying, "This file has been damaged by a disk error," with options to open anyway or to cancel.

I would like to have Photoshop systematically check all my other files to see if there are any additional problems. (I could of course just sit there and try to open all X-thousand images one by one, but I'd be there forever.)

So I thought I'd write an action to save resized copies, run all my images through it in a batch, and Photoshop would log any damaged-file errors to the batch error log. Trouble is I can't figure out how to automate an "OK" reply to the dialog box, and the message doesn't get recorded as an error in the errors log.

Is there any way to do this via scripting? The key piece of this is to capture which images throw up the error, and make a list of them somewhere. I can't be the first person who has wanted to do this...

Many thanks,
Andrew
This topic has been closed for replies.

3 replies

Participating Frequently
March 16, 2009
Can you just suppress dialogs and use a try block to open the image?

function openImage( file_name ) {

// store dialog mode
var dialog_mode = displayDialogs;
displayDialogs = DialogModes.NO;

// init flag
var file_valid = true;

// get file ref
var file_ref = File( file_name );

// try to open image
try {
// open file
open ( file_ref );

} catch( err ) {
// clear flag
file_valid = false;
}

// restore dialog mode
displayDialogs = dialog_mode;

// return success
return file_valid;

}
Known Participant
March 16, 2009
fazstp@adobeforums.com wrote:
> Can you just suppress dialogs and use a try block to open the image?
>
> function openImage( file_name ) {
>

There are some broken images that will slip by this technique. Instead of
throwing an exception (as it should), you get the 'damaged' dialog.

If you are running on XP, you can use a utility like AutoHotKey to automatically
hit the 'damaged' dialog which results in the above openImage function
returning false.


Here's what I originally wrote on the topic:
http://www.ps-scripts.com/bb/viewtopic.php?p=8519&sid=710f64b04bc6cfb71aa4bc5f2b3d3cc0


I never could find anything that would automatically take care of the 'damaged'
dialog on the Mac, so, for a lot of people, this is a less than complete solution.

-X
Participant
March 4, 2009
Good question. Unfortunately, I think the answer is no. The JS log for opening and immediately closing a damaged file looks exactly the same as that for a normal file; ditto for the VB log.
c.pfaffenbichler
Community Expert
Community Expert
March 4, 2009
Does the Error-message get recorded when opening with Scripting-Listener?