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.
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
...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.
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?)
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.
Copy link to clipboard
Copied
Haven't tried this myself, by maybe trying to load it as viewless document might work?