I have a project that I have filled with scene files that I recovered from
an old disk using PhotoRec on Linux (amazing tool, it has to be said!)

They all have the Softimage scene file header (so I can't check that!) but
may overrun in file length rendering them invalid and useless.  It may turn
out that they are all invalid, however there is a chance that some are OK.

I want to leave a script running that will attempt to open each scene and
if it succeeds, re-save it with _rec appended to the scene name.

Writing the script was easy, however when I run it in the interface
OpenScene opens a dialog saying "path....\blah.scn could not be found."
with an OK button.  Obviously this will not do and OpenScene offers no way
to suppress these warnings.

Not a problem I thought, as I'll be running it using xsibatch -script in
any case and that will just carry on chugging and I can try/except away the
errors without having to deal with any popup warnings.

Here's what I have:

# ----- BEGIN -----

import os

xsi = Application
pr = xsi.LogMessage

importpath = "E:\\Photorec\\RecoveredScenes\\Scenes\\"
sceneFileNameList = os.listdir(importpath)[::-1]#This reverses the list as
listdir is backwards!

for sceneFileName in sceneFileNameList:
 sceneFilePath = importpath + sceneFileName
try:
pr("Attempting to open: " + sceneFileName)
 xsi.OpenScene(sceneFilePath, False)
pr(sceneFileName + " is a valid Scene file - Resaving!!!")
 xsi.SaveSceneAs(sceneFilePath + "_rec.scn", "")
except:
pr("Invalid Scene file! - Skipping!!!")
xsi.Quit()

# ----- END -----

Here's what happens in batch:

# INFO : Attempting to open: f0305680.scn
>Loading: E:\Photorec\RecoveredScenes\Scenes\f0305680.scn...
Failed to load :   Error code: 80030002.
# ERROR : 2000 - Failed to load :   Error code: 80030002.
#
# WARNING : 3030-FILE-OpenScene - Command was cancelled.
Application.OpenScene("", False, "")
Command failed, returned -2146827065
# INFO : Invalid Scene file! - Skipping!!!

...it then gives me this for every scene thereafter, valid or not ( I've
thrown some valid scenes into the folder to be sure, and they are also
logged in this manner )

# INFO : Attempting to open: f0343048.scn
# INFO : Invalid Scene file! - Skipping!!!

So does anyone have any ideas on how best to approach this?  Do I need to
do something clever with this?
http://docs.python.org/2/library/sys.html#sys.exc_info

Thanks,

DAN

Reply via email to