open last maya scene founded by modification date


#1

Hi,
I am a newbe to Python… I am trying to find a simple way to open a maya scene with python in windows,
depending on his modification date,
as an example i wrote this code who is a mix between python, maxscript and mal…if someone know how to translate it in python, it would be wonderfull!
by advance thanks for help,


# Find all files in a directory with extension .ma in Python
import glob
for f in glob.iglob("G:/ProjectPath/241/*/001/LGT/*.ma"): 
    print f
    print count(f)
    # if several maya scenes founded, find the last one by modification date:
    if f.count > 1:      	 
		filesModDateArr = for i in f collect (getFileModDate i)					
		lastModifiedDate = amax  filesModDateArr
		index = findItem filesModDateArr lastModifiedDate
		lastModifiedFile = filesArr[index]
		# open last maya scene founded:
		file -f -options "v=0;p=17;f=0"  -ignoreVersion  -typ "mayaAscii" -o lastModifiedFile ;addRecentFile( lastModifiedFile, "mayaAscii");	


#2

If you want to learn Python, so you already know the steps to execute. Try it yourself, searching on stackoverflow could help a bit. Getting the latetes modified file in a directory took me about 10 sec. to find a solution in the web. Once you have the file, have a look at the Maya manuals how to open it. You almost have it, just correct the syntax and it will work in Python.


#3

Thanks Haggi, but i already found how