• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

any way of checking for corrupt .psd before loading?

New Here ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

at work we can batch download all the retouched .psd files from our DAM.

The stylists tend to only do this every month or so, and they don't have photoshop at home or an easy means of converting them to file types that they could actually use themselves.

I have an easy, simple script that converts all psds in a folder and all its subfolders to jpeg and saves them to a JPEGS folder.

But due to the obnoxious tendency of our DAM to not download a random PSD correctly, the occasional corrupt file will be in the bunch. The alert box for this file tanks the script

any suggestions on a means of validating the file isn't corrupt before having the script open it? I suppose i could attempt to do it by file size, but sizes aren't standard and it'd be a best guess that assumes the file is corrupt because it didn't download in its entirety . . . that solution sounds fragile and messy.

TOPICS
Actions and scripting

Views

877

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Feb 18, 2017 Feb 18, 2017

try/catch doesn't work when opening corrupted  image files. PS throws up a 'This file is corrupt' modal dialog which basically stops your script in its steps until the user clicks on the OK button. The only way to get around this is to use something like AutoHotKey on Windows. OS X provides some built in support that also will automatically press the OK button for you.

If need be, there are open source apps that parse PSD files that you could use via app.system() to determine if the file was corr

...

Votes

Translate

Translate
Adobe
Advocate ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

Which scripting language are you using?

In JavaScript, you have the try…catch construct, which allows you to catch errors, and continue accordingly.

In Applescrript, you have try…on error, which essentially does the same

I don't know what is available in VBS.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

Javascript, i'll read up on try catch.

the error is typically an unexpected end of file, if memory serves. it's hard to reproduce intentionally (unless someone knows how to corrupt a PSD on purpose?)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Feb 18, 2017 Feb 18, 2017

Copy link to clipboard

Copied

try/catch doesn't work when opening corrupted  image files. PS throws up a 'This file is corrupt' modal dialog which basically stops your script in its steps until the user clicks on the OK button. The only way to get around this is to use something like AutoHotKey on Windows. OS X provides some built in support that also will automatically press the OK button for you.

If need be, there are open source apps that parse PSD files that you could use via app.system() to determine if the file was corrupted before trying to open it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 19, 2017 Feb 19, 2017

Copy link to clipboard

Copied

LATEST

Haven't tried this myself, by maybe trying to load it as viewless document might work?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines