# "Copy to Clipboard" tree representation when expanded folders enabled

**URL:** <https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596>\
**Category:** Help & Support\
**Tags:** feature-request\
**Created:** [July 1, 2024, 9:52pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596 "2024-07-01T21:52:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![filewrangler](https://resource.dopus.com/user_avatar/resource.dopus.com/filewrangler/32/38654_2.png) [@filewrangler](https://resource.dopus.com/u/filewrangler)\
**Post date:** [July 1, 2024, 9:52pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/1 "2024-07-01T21:52:56Z")

</div>

When we [select some Name column cells](https://docs.dopus.com/doku.php?id=basic_concepts:selecting_files:selecting_cells), i.e. files or folders (not date or type column cells etc), from the file display _with folder expansion is enabled_, it would be great if we could copy the selected cells as a tree representation. Meaning, something similar to using the Windows `tree` command.

Normally I can run `tree` on a path (e.g. via a button script), then edit it after the fact in a text editor to remove any unwanted files or unnecessarily deep paths from the tree representation, but this is tedious and error prone. This proposed feature would be like a live edit of the final tree representation before you copy it.

So for this example cell selection from the Name column:

![dopus_2024-07-01_23-28-50](https://resource.dopus.com/uploads/default/original/3X/e/a/eae18b4f242ddfff02618c818131ea3c541747c4.png)

Using the `tree /F` command's output _style_ as a guide, we'd copy:

> Note the lack of _broadcast.js_ since that Name cell isn't selected (despite the _steamui_ folder being selected and expanded), as well as the lack of the unselected file cells directly under _Steam_.

```plaintext
C:\Program Files (x86)\Steam
│ GameOverlayUI.exe.log.last
│ Steam.dll
│ steam.exe
│
├───steam
├───steamapps
├───steamchina
├───steamui
└───steamui-public

```

The difference between this FR and `tree` is that `tree` can only accept a single path and it always goes to the max depth. This FR however would limit the tree representation to the selected cells -- or just the visible cells under the selected expanded folder cell.

I imagine 2 hypothetical options to be added to selected cells' right-click menu:

- _Copy to Clipboard (tree as selected)_ (like the example above).
- _Copy to Clipboard (tree as expanded)_ (like the example below).

![dopus_2024-07-01_23-35-00](https://resource.dopus.com/uploads/default/original/3X/4/2/42e85dfc5fac00ec23734239891e0b449c7b6656.png)

In this second example, only 2 cells are selected, but we could use the just mentioned _Copy to Clipboard (as expanded)_ option instead which would copy the following tree representation to the clipboard:

> Note the inclusion of _broadcast.js_ this time and all the files beneath _Steam_, also, the _RivaTuner Statistics Server_ folder is included, but because it's not expanded, only the folder is added to the tree representation, not any of its contents.

```plaintext
C:\Program Files (x86)\RivaTuner Statistics Server
C:\Program Files (x86)\Steam
│ GameOverlayUI.exe.log.last
│ Steam.dll
│ steam.exe
│ steam.signatures
│ Steam2.dll
│ <other file cells beyond the screenshot>
│
├───steam
├───steamapps
├───steamchina
├───steamui
    │ broadcast.js
├───steamui-public
└───steamui-public

```

Presumably this feature would be limited to only when folder expansion is enabled as I'm not sure how well it would work in flat view for example. I'm also not sure how well I explained the idea, or if it's worth the effort to implement, but the idea came over me and I thought I'd see it through. Would anyone else find this useful?

Thanks.

Opus 13.7.1

---

<div class="post-metadata">

**Author:** ![errante](https://resource.dopus.com/user_avatar/resource.dopus.com/errante/32/61692_2.png) [@errante](https://resource.dopus.com/u/errante)\
**Post date:** [July 2, 2024, 12:50am UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/2 "2024-07-02T00:50:25Z")

</div>

FWIW, this can be done via a script (IMHO it's a good exercise to develop basic scripting skills).  
If you don't mind, can you share a real life scenario where this could be useful?

---

<div class="post-metadata">

**Author:** ![filewrangler](https://resource.dopus.com/user_avatar/resource.dopus.com/filewrangler/32/38654_2.png) [@filewrangler](https://resource.dopus.com/u/filewrangler)\
**Post date:** [July 2, 2024, 1:06pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/3 "2024-07-02T13:06:52Z")

</div>

> [@errante](#):
>
> FWIW, this can be done via a script (IMHO it's a good exercise to develop basic scripting skills).

I agree, but so could the choices that Opus ships with. I just thought it might be useful to offer another way of copying cells:

 ![dopus_2024-07-02_15-51-24](https://resource.dopus.com/uploads/default/original/3X/5/d/5d80a0c069c396c30d29ae0367c8f3f34cced37a.png)

I'd probably have a hard time getting the FR working as I have described, but sure, perhaps it should be left to the community to create.

> [@errante](#):
>
> If you don't mind, can you share a real life scenario where this could be useful?

The reason I even began thinking about this is because I wanted to show somebody (a bug report) what files and folders were present on my system, without exposing anything irrelevant or personal.

Usually I'd either take a screenshot and censor some items after the fact if necessary. The reasons why I thought a text tree representation would be better than a screenshot is that it's both searchable, and easier and faster to edit without any special tool. But why censor or edit when you could select exactly what you wish to share before copying? Hence this FR.

---

<div class="post-metadata">

**Author:** ![errante](https://resource.dopus.com/user_avatar/resource.dopus.com/errante/32/61692_2.png) [@errante](https://resource.dopus.com/u/errante)\
**Post date:** [July 2, 2024, 2:23pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/4 "2024-07-02T14:23:31Z")

</div>

Understandable. Thanks.  
But are you referring to whether it works with the selected **items** or with the selected **cells** , as in your screenshot?  
Note that there are some slight differences, when wanting to make a script command for one or the other. For example, if you are talking about cells, it is possible to select values other than the name. What should the script do in that case? Always use only names? Also include the values of selected cells? For everyone or only for the selected ones?

---

<div class="post-metadata">

**Author:** ![filewrangler](https://resource.dopus.com/user_avatar/resource.dopus.com/filewrangler/32/38654_2.png) [@filewrangler](https://resource.dopus.com/u/filewrangler)\
**Post date:** [July 2, 2024, 4:34pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/5 "2024-07-02T16:34:58Z")

</div>

> [@errante](#):
>
> For example, if you are talking about cells, it is possible to select values other than the name. What should the script do in that case? Always use only names? Also include the values of selected cells?

The only reason I went the cells route for this suggestion is that that is how we copy File Display information currently (Ctrl + Right-clicking to select cells, then right-clicking to copy them via context menu). The feature could alternatively be done using normal selection of File Display items (Ctrl / Shift + left-clicking), but where would the copy feature be triggered from? It seemed to be worth grouping with the cell copying features as seen in the previous screenshot.

I used the terminology "Name cells" because it would only work with those. If other cells for different columns were selected, they could either just copy the Name cell for that row anyway, or ignore the cell because the other cells don't really have a place in a tree representation (unless we want to start adding e.g. file size and other info to each of the tree's items:

```plaintext
C:\Program Files (x86)\Steam [1.56 GiB; Modified: 2024-07-02]
...
│ steam.exe [4.20 MiB; Modified: 2024-07-02]
│ steam.signatures [4.45 KiB; Modified: 2024-07-02]
...

```

...but that's beyond what I was originally thinking.

> [@errante](#):
>
> For everyone or only for the selected ones?

As I outlined, there could be two options: _Copy to Clipboard (tree as selected)_ and _...as expanded_. The latter would be more like for every Name cell under selected folder cells (but only if that folder is also expanded -- that's the live edit aspect).

It's possible the idea could be improved upon as you might want an even simpler third copy operation, i.e. one which disregards if the select folder cell is expanded or not, but then the copied result becomes just two or more `tree` commands joined together, which still has its uses as you could still use it to omit paths you don't want in the tree:

```plaintext
A
├───B1
├───B2
└───B3

```

To make a tree of the folders `B1` and `B3`, instead of normally having to pass `A`'s path to `tree` then edit the output after to erase `B2` and the indentation from `A`, you could highlight `B1` and `B3` and effectively get two `tree`s joined together at the root level of indentation. I only use `tree` as an example. There are probably tools which are far better than it, i.e. which support multiple paths, exclusions etc when defining a text tree to draw. That might be what I need to look into, but passing selected cells to a third-party program wouldn't consider if the folder cell is expanded or not I guess.

The reason for the copy operation considering whether a folder is expanded or not was only suggested as it would give you control over whether the contents of a folder is also included or only its presence (i.e. none of its child items, just the folder). These ideas could do with further simplifying I think.

Hopefully I'm making sense.

---

<div class="post-metadata">

**Author:** ![errante](https://resource.dopus.com/user_avatar/resource.dopus.com/errante/32/61692_2.png) [@errante](https://resource.dopus.com/u/errante)\
**Post date:** [July 2, 2024, 8:08pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/6 "2024-07-02T20:08:15Z")

</div>

What would be the output if, as in your first example, you select the 'Steam' folder and the broadcast.js' file only?

---

<div class="post-metadata">

**Author:** ![ThioJoe](https://resource.dopus.com/user_avatar/resource.dopus.com/thiojoe/32/42549_2.png) [@ThioJoe](https://resource.dopus.com/u/ThioJoe)\
**Post date:** [July 2, 2024, 9:37pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/7 "2024-07-02T21:37:41Z")

</div>

If you're going to write a script for it, this other script I made might have some logic in there that might be helpful: [Script for copying selected relative file paths list from Flat View](https://resource.dopus.com/t/script-for-copying-selected-relative-file-paths-list-from-flat-view/51126)

It's for a different purpose and only works with selected files, but some of it will be relevant like how it gets the relative paths. You could also subtract the sourcePathDepth and initialDepth variables to calculate the length of the tree branches for each file for example.

Edit: Actually I gave ChatGPT my original script and told it to generate a new one that draws a tree instead, and it actually worked 💀 I'll probably touch it up a bit with additional features when I get the chance and make a thread for it, but I'll paste it below. At the moment it only works with selected files/folders but I'll see about adding stuff to give it the expanding options you mentioned. Also right now it seems to draw the tree a bit funky with an extra layer of lines at the bottom level of selected files.

Edit 2: I polished up the script, here's a thread with it: [Script / Command for copying tree view of selected files & folders](https://resource.dopus.com/t/script-command-for-copying-tree-view-of-selected-files-folders/51628)

---

<div class="post-metadata">

**Author:** ![GioFar](https://resource.dopus.com/letter_avatar_proxy/v4/letter/g/c2a13f/32.png) [@GioFar](https://resource.dopus.com/u/GioFar)\
**Post date:** [August 30, 2025, 3:36pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/8 "2025-08-30T15:36:09Z")

</div>

I've created this, not too sure if it's exactly what you're looking for though.  
You must select a folder and the button will copy as tree graph the structure, has warnings if you don't have a folder selected, and then ask if you want to include files or just folders, and also if you want the root to be displayed just with the name, or global path.

As an example, pressing the button with the folder "frontend" selected will give this:

## Includes file, root folder name.

frontend  
├─ Dockerfile  
├─ package.json  
├─ src  
│ ├─ api.ts  
│ ├─ App.tsx  
│ ├─ components  
│ │ └─ PrivateRoute.tsx  
│ ├─ context  
│ │ └─ AuthContext.tsx  
│ ├─ hooks  
│ └─ pages  
│ └─ TodoList.tsx  
└─ tests  
└─ TodoList.test.tsx

## Only folders, root folder name.

frontend  
├─ src  
│ ├─ components  
│ ├─ context  
│ ├─ hooks  
│ └─ pages  
└─ tests\

## Includes files, root as global.

D:\My Temp\todo-app\frontend  
├─ Dockerfile  
├─ package.json  
├─ src  
│ ├─ api.ts  
│ ├─ App.tsx  
│ ├─ components  
│ │ └─ PrivateRoute.tsx  
│ ├─ context  
│ │ └─ AuthContext.tsx  
│ ├─ hooks  
│ └─ pages  
│ └─ TodoList.tsx  
└─ tests  
└─ TodoList.test.tsx

## Only folders, root as global.

D:\My Temp\todo-app\frontend  
├─ src  
│ ├─ components  
│ ├─ context  
│ ├─ hooks  
│ └─ pages  
└─ tests\

If that's what you are looking for, here's the button

[Copy folder tree.dcf](https://resource.dopus.com/uploads/short-url/frFPD2g7Ym2z3QimrOovcS29mcU.dcf) (4.5 KB)

---

<div class="post-metadata">

**Author:** ![GioFar](https://resource.dopus.com/letter_avatar_proxy/v4/letter/g/c2a13f/32.png) [@GioFar](https://resource.dopus.com/u/GioFar)\
**Post date:** [August 30, 2025, 11:10pm UTC](https://resource.dopus.com/t/copy-to-clipboard-tree-representation-when-expanded-folders-enabled/51596/9 "2025-08-30T23:10:00Z")

</div>

I don't seem to be able to edit my post, so I'll add it here.

After looking at the result of the button, I realised that I wanted to tweak it long ago and never remembered, until today.

This is a better vesion, same functions, but instead of ordering alphabetically files and folders mixed together, it will list folders at the top and files at the bottom, which is more natural.

I'm not gonna repeat all 4 options to save space, but just to give an idea, here one example.

frontend  
├─ src  
│ ├─ components  
│ │ └─ PrivateRoute.tsx  
│ ├─ context  
│ │ └─ AuthContext.tsx  
│ ├─ hooks  
│ ├─ pages  
│ │ └─ TodoList.tsx  
│ ├─ api.ts  
│ └─ App.tsx  
├─ tests  
│ └─ TodoList.test.tsx  
├─ Dockerfile  
└─ package.json

[Copy folder tree v2.dcf](https://resource.dopus.com/uploads/short-url/3HwccoSZG39vdugWhJPE9iRmOQS.dcf) (6.1 KB)
