14 Replies Latest reply on Jan 28, 2011 7:39 AM by Muppet Mark-QAl63s

    Skip damaged file message

    Col84

      I've created a script which opens images in photoshop and then edits then. Everything has been working fine until I came across one this morning which produced the following message... "This document may be damaged (the file may be truncated or incomplete) continue?". When I manually clicked continue it opened the image and then continued.

       

      Now, most of the time this script runs when I'm not at the computer and obviously the idea of scripting is to be automated so is there anyway to automatically "click" continue if this happens again?

       

      Thanks for your help.

        • 1. Re: Skip damaged file message
          Muppet Mark-QAl63s Level 4

          This can be done with AppleScript on the mac. May be possible with VB on the PC too? Outside the reach of ExtendScript unless you can call out to which ever of those other languages suits your OS…

          • 2. Re: Skip damaged file message
            xbytor2 Level 4

            You can wrap the app.open() call in a try/catch block which will let you skip some corrupted files but not all. This has been a known problem for many years.

            • 3. Re: Skip damaged file message
              Col84 Level 1

              How would it be done with AppleScript then? I'm currently using VBScript.

               

               

              So if I use a try/catch block what would I need to add to get it to skip / "click" continue ? ...

               

              Dim docRef

                   fileName = "C:\test.jpg"

                        Try

                             docRef = appRef.Open(fileName)

                        Catch ex As Exception
                                

                        End Try

               

               

              Thanks for your replies.

              • 4. Re: Skip damaged file message
                xbytor2 Level 4

                On Windows, I used an app called AutoHotKey, a keyboard macro program. I configured it to watch for the damaged file dialog from Photoshop and have it click the Continue button. This usually worked.

                 

                I was never able to get the equivalent AS script working but that may because I'm practically illiterate in AS. I don't recall anybody ever posting a working solution for OS X.

                1 person found this helpful
                • 5. Re: Skip damaged file message
                  Col84 Level 1

                  I don't need it to work in apple script. Ideally I'd like a solution in vbscript, it was just with Mark saying "This can be done with AppleScript on the mac", I was just interested to know roughly how it was done to see if I could do the same thing in vbscript.

                   

                  So the only way to solve this then is with an external app?

                   

                  I came across something similar last week. I can't remember the exact error message but when opening an image I think it said something along the lines of "there might be a problem with this file". BUT, in the error box it had a tick box saying "don't show this message again". When I clicked ok it again worked fine and because I'd ticked the box, when opening the same image the message never appeared again. I thought that would be the last time I saw a file error message but now I've come across this new one!

                   

                  Thanks.

                  • 6. Re: Skip damaged file message
                    xbytor2 Level 4
                    So the only way to solve this then is with an external app?

                     

                    It's the only way I've been able to get this to work.

                     

                    I thought that would be the last time I saw a file error message but now I've come across this new one!

                     

                    Depending on how a file is corrupted, PS may throw a JS exception or put up this annoying dialog. If you got a dialog with a tick box, it would imply that there are some corruption modes that PS feels is OK for it to auto-correct when opening a file. I haven't seen it, BTW.

                    • 7. Re: Skip damaged file message
                      Muppet Mark-QAl63s Level 4

                      With AppleScript you can wrap the opening command inside of a 'timeout' block. Photoshop does NOT kick an error back but the timeout throws the error after a couple of seconds with that you command the keystroke.

                       

                      try

                      with timeout of 2 seconds

                      open The_File

                      end timeout

                      on error

                      tell application "System Events"

                      tell application process "Adobe Photoshop CS2"

                      keystroke return

                      end tell

                      end tell

                      end try

                       

                      I wouldn't know if there is any such method in VB? I could not get anything to work with calling out to app.system();

                      1 person found this helpful
                      • 8. Re: Skip damaged file message
                        Col84 Level 1

                        Mark, that sort of solution would be ideal.

                         

                        Hopefully it will be possible to do the same thing with VB instead. I'll have to look into that.

                         

                         

                        Thanks.

                        • 9. Re: Skip damaged file message
                          xbytor2 Level 4

                          From experience, you may want try different timeout values. Big PSD files can take a lot longer than 2 seconds depending on your rig.

                          • 10. Re: Skip damaged file message
                            Col84 Level 1

                            @ xbytor2 - Don't suppose you know how to do the equivalent with a timeout in VB do you?

                             

                            Thanks.

                            • 11. Re: Skip damaged file message
                              xbytor2-psZgZs

                              Sorry, no. I am also VB illiterate.

                              • 12. Re: Skip damaged file message
                                Col84 Level 1

                                No problem, thanks anyway.

                                 

                                I think I'm going to look into the autohotkey solution instead then. I've downloaded the app and hopefully that will be more straight forward to just look out for that dialog box and click continue!

                                 

                                 

                                Thanks both for your help.

                                • 13. Re: Skip damaged file message
                                  Col84 Level 1

                                  All sorted now with AutoHotKey :-)

                                  • 14. Re: Skip damaged file message
                                    Muppet Mark-QAl63s Level 4

                                    Just to see if this was possible via another method on OSX. I made an AppleScript app that I can launch before running an ESTK PS script. It's a bit doppy in it's response times (around 5-20 seconds Im not sure why that is)… but did work. I will see if I can re-word it and make it work any better…

                                     

                                    on run

                                     

                                    delay 1

                                     

                                    end run

                                     

                                    on idle

                                     

                                    tell application "System Events"

                                    try

                                    set ps to the first process whose name contains "Photoshop"

                                    if frontmost of ps is true then

                                    tell window 1 of ps

                                    if title is "Adobe Photoshop" then

                                    tell ps to keystroke return

                                    end if

                                    end tell

                                    end if

                                    end try

                                    end tell

                                     

                                    end idle