I noticed a strange thing in Maya. I would like to know if you guys got the same problem or if I am doing something wrong?
There is the cmds.file command. The documentation says it got a "shortName" flag which should return the currently opend scenename without the complete path.
cmds.file(query = True, shortName = True)
# Error: RuntimeError: file <maya console> line 1: Flag cannot be queried. #
Also the doc. says that shortName is a queryable flag.
I also tried to just use the sceneName flag which should return the complete path of the currently opend file. Which indeed it does. But when I set it to "False" it gives me the same error you saw above.
This happens on Maya 2016 and Maya 2017.
The doc: http://help.autodesk.com/cloudhelp/2016/ENU/Maya-Tech-Docs/CommandsPython/file.html#flagshortName
Thanks for reading and have a nice day!
I'm not sure if you tried the command in the right way, but what the documentation says is:
When used with a main query flag it indicates that the file name returned will be the short name
So, in this situation the main query flag could be sceneName
and then the shortName
can be specified, to get just the filename.
import maya
print maya.cmds.file(query=True, sceneName=True, shortName=True)
Anyway, if you want to have a little more control over the specific path manipulation, may I suggest you to use the python os module? Or even better the os.path module?