# View all content command in python

**URL:** <https://forum.dynamobim.com/t/view-all-content-command-in-python/78843>\
**Category:** Revit\
**Tags:** python, dynamo\
**Created:** [July 19, 2022, 8:07pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843 "2022-07-19T20:07:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ammed.riveros](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@ammed.riveros](https://forum.dynamobim.com/u/ammed.riveros)\
**Post date:** [July 19, 2022, 8:07pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/1 "2022-07-19T20:07:22Z")

</div>

Very good afternoon with all…  
I’m learning PYTHON and I’m learning how to import external libraries.  
I would like to know what command I should type in order to see ALL THE CONTENT OF THE FOLDER I am addressing… thanks…

 ![02_VER EL CONTENIDO DE CARPETA DE LIBRERIAS](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/d/fd1490855fbd3f316e7d4e280359d631dac02fe8.jpeg)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 19, 2022, 8:29pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/2 "2022-07-19T20:29:24Z")

</div>

@ammed.riveros ,

can you try

```auto
OUT = dir(sys)

```

---

<div class="post-metadata">

**Author:** ![ammed.riveros](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@ammed.riveros](https://forum.dynamobim.com/u/ammed.riveros)\
**Post date:** [July 19, 2022, 9:23pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/3 "2022-07-19T21:23:41Z")

</div>

@Draxl_Andreas  
he content that a DIR gives me is not the content that is in the directory path…  
I want to see the contents of the folder.

 ![03_VER EL CONTENIDO DE CARPETA DE LIBRERIAS](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/c/ac7f2d5fe92e03749873138ff9f2df84d9c14a2d.jpeg)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 20, 2022, 6:50am UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/4 "2022-07-20T06:50:45Z")

</div>

@ammed.riveros ,

Just “dir” it again…  
🙂

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/4/647924c5e1568bb982128289ad359077534c1d19.png)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [July 20, 2022, 1:29pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/5 "2022-07-20T13:29:40Z")

</div>

Hello,  
an example, to see all modules/packages loaded (.Net and Python)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/5/e509dae19d5b13d751cb73e516a08986f8f3ac8a.png)

```auto
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import System

assemblies = System.AppDomain.CurrentDomain.GetAssemblies()

for a in System.AppDomain.CurrentDomain.GetAssemblies():
    if a.GetName().Name == 'IronPython.Modules':
        mods = a
        break
  
nativeIronpythonModule = [m.Key for m in mods.IronPython.Modules]
pythonimportModules = sys.modules.keys()
OUT = assemblies, nativeIronpythonModule, pythonimportModules

```

---

<div class="post-metadata">

**Author:** ![ammed.riveros](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@ammed.riveros](https://forum.dynamobim.com/u/ammed.riveros)\
**Post date:** [July 20, 2022, 5:05pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/6 "2022-07-20T17:05:35Z")

</div>

I was only looking to know the name of the files and their extension… because they are difficult…  
I don’t understand anything… instead of being motivated to learn… now I want to learn it less… 😭 😭 😭 😭 😭 …  
Why is it so difficult to get just what I’m looking for… I just want to know the names and their extension of everything that is inside the folder… NOTHING ELSE… I’m not interested in knowing other things… I get confused more

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 20, 2022, 6:19pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/7 "2022-07-20T18:19:19Z")

</div>

@ammed.riveros ,

“Be water my friend…” Bruce Lee

---

<div class="post-metadata">

**Author:** ![ammed.riveros](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@ammed.riveros](https://forum.dynamobim.com/u/ammed.riveros)\
**Post date:** [July 20, 2022, 9:07pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/8 "2022-07-20T21:07:00Z")

</div>

🤦‍♂️ 🤦‍♂️ 🌋

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [July 20, 2022, 9:32pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/9 "2022-07-20T21:32:42Z")

</div>

Is this more of what you were looking for @ammed.riveros

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/a/9a97b0726efaf039635604ea89a96b41aaeca4a7.png)

```auto
import sys
# Use a variable for the path to be able to call it other functions
iPath = 'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(iPath)

# To check contents of operating system
import os

files = []
folders = []

# Get the contents of the directory
directory_contents = os.listdir(iPath)

# Check contents for type sorting
for path in directory_contents:
    # check if current path is a file by combining the directory and the path item
    if os.path.isfile(os.path.join(iPath, path)):
        # Its a file
        files.append(path)
    else:
        # Its a folder
        folders.append(path)

OUT = files,folders

```

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [July 21, 2022, 7:14am UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/10 "2022-07-21T07:14:20Z")

</div>

> [@ammed.riveros](#):
>
> I just want to know the names and their extension of everything that is inside the folder… NOTHING ELSE… I’m not interested in knowing other things… I get confused more

here an example, but what is the end goal?, you search a library before import ?

```auto
import sys
import clr
import System
from System.IO import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

my_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)
pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)

ironpath = pf_path + '\\IronPython 2.7\\Lib'
sys.path.append(ironpath)

lstFiles = Directory.GetFiles(ironpath, "*", SearchOption.TopDirectoryOnly)

lstDir = Directory.GetDirectories(ironpath, "*", SearchOption.TopDirectoryOnly)

OUT = list(lstDir) + list(lstFiles)

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/4/c4234084d6e89e4b07ccae4ba3b65a70fd8469e0.png)

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [July 21, 2022, 9:07am UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/11 "2022-07-21T09:07:13Z")

</div>

See if this page helps: [Python - List Files in a Directory - GeeksforGeeks](https://www.geeksforgeeks.org/python-list-files-in-a-directory/#:~:text=Python%20now%20supports%20a%20number%20of%20APIs%20to,all%20files%20and%20directories%20in%20a%20specified%20directory.)

---

<div class="post-metadata">

**Author:** ![ammed.riveros](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@ammed.riveros](https://forum.dynamobim.com/u/ammed.riveros)\
**Post date:** [July 22, 2022, 10:48pm UTC](https://forum.dynamobim.com/t/view-all-content-command-in-python/78843/12 "2022-07-22T22:48:13Z")

</div>

Gracias…
