# Get the \_\_file\_\_ in Maya

**URL:** https://forum.highend3d.com/t/get-the---file---in-maya/161546
**Category:** Maya
**Tags:** python
**Created:** [March 29, 2020, 10:22am UTC](https://forum.highend3d.com/t/get-the---file---in-maya/161546 "2020-03-29T10:22:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![schocki](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/47e85d/32.png) [@schocki](https://forum.highend3d.com/u/schocki)
#### Post date: [March 29, 2020, 10:22am UTC](https://forum.highend3d.com/t/get-the---file---in-maya/161546/1 "2020-03-29T10:22:41Z")

</div>

When I run this script:

`import os.path

try:  
approot = os.path.dirname(os.path.abspath( **file** ))  
except NameError:  
import sys  
approot = os.path.dirname(os.path.abspath(sys.argv[0]))

print approot`

through a line like this in a script editor:  
execfile(“C:\test.py”)#the path to the script

I always get ‘C:\Program Files\Autodesk\Maya2020\bin’ not the the path to the script.  
Why?

---

<div class="post-metadata">

### Author: ![system](https://forum.highend3d.com/user_avatar/forum.highend3d.com/system/32/59311_2.png) [@system](https://forum.highend3d.com/u/system)
#### Post date: [July 1, 2020, 2:29am UTC](https://forum.highend3d.com/t/get-the---file---in-maya/161546/2 "2020-07-01T02:29:30Z")

</div>

This topic was automatically closed after 93 days. New replies are no longer allowed.
