Lauloque
Lauloque

Reputation: 159

Batch run maya with last recent file

I try to make a batch file that basically opens all the stuff I need to work. Opening Maya is quite simple, but there's one step further i'd like to do: make it open my last opened file. if i understand the doc Start Maya from the command line

I could try this:

path/to/maya.exe -command [some MEL commands that may open the last opened file]

But I have no clue how to MEL and I guess for it to work as a windows batch I must keep it as one command line. I try to read the docs but I fail to find anything I can make use of.

python("recent = cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, force=True, open=True)")

Issues:

Solutions

Thanks to this answer:

"path\to\maya.exe" -command "python(\"recent=cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, force=True, open=True)\")"

Upvotes: 0

Views: 849

Answers (1)

haggi krey
haggi krey

Reputation: 1978

  1. Usually you replace a " with a \" to get a working mel command. So if you this could work:

    "python(\"recent = cmds.optionVar(q='RecentFilesList')[-1]; cmds.file (recent, open=True)\")"

But to be honest I did not test it as a commandline argument.

  1. You can modify the file command with force:

    cmds.file(recent, force=True, open=True)

Upvotes: 1

Related Questions