# Show folder content in custom context menu

**URL:** <https://community.folivora.ai/t/show-folder-content-in-custom-context-menu/39331>\
**Category:** Configuration Help & General Discussion\
**Created:** [September 24, 2024, 5:35pm UTC](https://community.folivora.ai/t/show-folder-content-in-custom-context-menu/39331 "2024-09-24T17:35:16Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [October 2, 2024, 10:51am UTC](https://community.folivora.ai/t/show-folder-content-in-custom-context-menu/39331/12 "2024-10-02T10:51:20Z")

</div>

Ah you are right, sorry I remembered that incorrectly.

You could however switch to a different command like ls for simple lists of files:

```auto
async function retrieveJSON() {
    let folder = "/Users/andreas/Documents";
  
    // Construct the shell script to recursively list all files using ls
    let script = `ls "${folder}"`;
  
    let filePaths = await runShellScript({
      script: script,
    });
  
    // Split the file paths by new line
    let fileArray = filePaths.split("\n").filter(Boolean); // filter(Boolean) removes any empty lines
  
    // Create an array of objects with filePath and fileName
    let files = fileArray.map((filePath) => {
      let fileName = filePath.split("/").pop(); // Extract the file name from the path
      return { filePath, fileName };
    });
  
    let menuItems = [];
  
  
    // Create the context menu items that trigger a shell script to open the file
    for (let file of files) {
      let item = {
        title: file.fileName,
        action: `js::(async () => {runShellScript({script: 'open "${folder + '/' + file.filePath}"'})})()`,
        icon: `sfsymbol::doc.circle`
      };
      menuItems.push(item);
    }
  
    return JSON.stringify(menuItems);
  }
  

```

(by the way, one of the next versions will also allow to use these scripts in floating menus to dynamically retrieve their items)

---

_[View the full topic](https://community.folivora.ai/t/show-folder-content-in-custom-context-menu/39331)._
