<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I get the filepath of a script that is loaded into the script editor? in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11530393#M1699</link>
    <description>&lt;P&gt;Hi fellow Maya Programmers!&lt;BR /&gt;&lt;BR /&gt;I need some help figuring out a script's filepath from within maya using python. I have a certain script file located somewhere on my harddrive. Let's assume the file is called "C:/Users/Username/Desktop/test.py". In Maya's Script Editor I open the script file using "File" -&amp;gt; "Open Script..." Menu. A new Tab in my script editor appears, displaying the content of my test.py. What I am trying to do now, is run the test.py and print the folder location where that file (test.py) is stored.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there anyway to extract that path information?&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 09:12:53 GMT</pubDate>
    <dc:creator>marten.zanderBH2FZ</dc:creator>
    <dc:date>2022-11-04T09:12:53Z</dc:date>
    <item>
      <title>How do I get the filepath of a script that is loaded into the script editor?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11530393#M1699</link>
      <description>&lt;P&gt;Hi fellow Maya Programmers!&lt;BR /&gt;&lt;BR /&gt;I need some help figuring out a script's filepath from within maya using python. I have a certain script file located somewhere on my harddrive. Let's assume the file is called "C:/Users/Username/Desktop/test.py". In Maya's Script Editor I open the script file using "File" -&amp;gt; "Open Script..." Menu. A new Tab in my script editor appears, displaying the content of my test.py. What I am trying to do now, is run the test.py and print the folder location where that file (test.py) is stored.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Is there anyway to extract that path information?&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 09:12:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11530393#M1699</guid>
      <dc:creator>marten.zanderBH2FZ</dc:creator>
      <dc:date>2022-11-04T09:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the filepath of a script that is loaded into the script editor?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11530828#M1700</link>
      <description>&lt;LI-CODE lang="general"&gt;import maya.cmds as cmds
def getScriptEditorPaths():
    # Get the name of the scriptEditorPanel
    allPanels = cmds.getPanel( all=True )
    
    scriptPanel = [x for x in allPanels if 'scriptEditor' in x]
    if not scriptPanel:
        return []
        
    scriptPanel = scriptPanel[0]
    
    # Step through the layouts of the script editor until we find the tablayout  
    f1 = cmds.layout(scriptPanel, q = True, childArray = True)
    f1, f2 = cmds.layout(formLayout1, q = True, childArray = True)
    p1 = cmds.layout(f2, q = True, childArray = True)
    sf, p2 = cmds.layout(p1, q = True, childArray = True)
    t1 = cmds.layout(p2, q = True, childArray = True)
    
    filePaths = []
    for eachChildLayout in cmds.tabLayout(t1, q = True, childArray = True):
        scrollFieldExec = cmds.layout(eachChildLayout, q = True, childArray = True)
        filePaths.append(cmds.cmdScrollFieldExecuter(scrollFieldExec, q = True, filename = True))
    
    return filePaths
    
getScriptEditorPaths()&lt;/LI-CODE&gt;&lt;P&gt;This should work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 12:46:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11530828#M1700</guid>
      <dc:creator>jmreinhart</dc:creator>
      <dc:date>2022-11-04T12:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the filepath of a script that is loaded into the script editor?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11531409#M1701</link>
      <description>&lt;P&gt;Hey man, thank you for your reply. unfortunately I get an error saying that global name "formLayout1" is not defined.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 15:50:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11531409#M1701</guid>
      <dc:creator>marten.zanderBH2FZ</dc:creator>
      <dc:date>2022-11-04T15:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get the filepath of a script that is loaded into the script editor?</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11531414#M1702</link>
      <description>&lt;P&gt;Okay, I actually fixed it by myself already. I replaced "formLayout1" with f1[0] :). It's working, thanks a lot!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 15:52:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/how-do-i-get-the-filepath-of-a-script-that-is-loaded-into-the/m-p/11531414#M1702</guid>
      <dc:creator>marten.zanderBH2FZ</dc:creator>
      <dc:date>2022-11-04T15:52:24Z</dc:date>
    </item>
  </channel>
</rss>

