# Copy paths of selected files to clipboard

**URL:** https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738
**Category:** Help & Support
**Created:** [September 20, 2007, 1:14pm UTC](https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738 "2007-09-20T13:14:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Daan](https://resource.dopus.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://resource.dopus.com/u/Daan)
#### Post date: [September 20, 2007, 1:14pm UTC](https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738/1 "2007-09-20T13:14:25Z")

</div>

Hi,

I have a button with this:

```auto
Clipboard COPYNAMES
```

This copies the full paths and the names of the selected files to the clipboard.

Another button has this code:

```auto
Clipboard COPYNAMES=nopaths
```

This does the same, but hides the paths. It copies only the filenames of the selected files to the clipboard.

Now, what I want to achieve is a button that copies all the paths (without the filenames) of the files that are selected (flat view: the selected files have different paths)

I can't come any closer than this:

```auto
@nofilenamequoting
Clipboard SET {filepath$|..}
```

The result is only one path. It's always the path of the last selected file.  
I think this code overwrites the clipboard for every selected file.

However, can anyone figger out the right code?

Thanks!

Daan

---

<div class="post-metadata">

### Author: ![kenalcock](https://resource.dopus.com/letter_avatar_proxy/v4/letter/k/5e9695/32.png) [@kenalcock](https://resource.dopus.com/u/kenalcock)
#### Post date: [September 20, 2007, 3:37pm UTC](https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738/2 "2007-09-20T15:37:45Z")

</div>

Use this button to copy the paths including the terminating backslash "" character.

`<?xml version="1.0"?>
<button display="label">
	<label>Copy Paths</label>
	<tip>Copies the folder paths of all selected files and folders to the clipboard (includes terminating &quot;\&quot;)</tip>
	<icon1>#copyfilenames</icon1>
	<function type="normal">
		<instruction>Clipboard COPYNAMES REGEXP &quot;(.*\\)([^\\]*)&quot; &quot;\1&quot;</instruction>
	</function>
</button>`

Use this button to copy the paths excluding the terminating backslash "" character.

`<?xml version="1.0"?>
<button display="label">
	<label>Copy Paths - noterm</label>
	<tip>Copies the folder paths of all selected files and folders to the clipboard (excludes terminating &quot;\&quot;)</tip>
	<icon1>#copyfilenames</icon1>
	<function type="normal">
		<instruction>Clipboard COPYNAMES REGEXP &quot;(.*)(\\)([^\\]*)&quot; &quot;\1&quot;</instruction>
	</function>
</button>`

Read This FAQ: [How to add example buttons to your toolbars and menus](https://resource.dopus.com/t/how-to-add-buttons-from-this-forum-to-your-toolbars/3546/1)

NOTE: The toolbar buttons above use an icon from this icon set: [Opus 9 Unofficial Extra Icons](https://resource.dopus.com/t/opus-9-unofficial-extra-icons-v1-1/4643/1).

---

<div class="post-metadata">

### Author: ![kenalcock](https://resource.dopus.com/letter_avatar_proxy/v4/letter/k/5e9695/32.png) [@kenalcock](https://resource.dopus.com/u/kenalcock)
#### Post date: [September 20, 2007, 3:41pm UTC](https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738/3 "2007-09-20T15:41:03Z")

</div>

You should also realize that you will most likely get duplicate paths in the clipboard using either button above.

---

<div class="post-metadata">

### Author: ![Daan](https://resource.dopus.com/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@Daan](https://resource.dopus.com/u/Daan)
#### Post date: [September 20, 2007, 4:06pm UTC](https://resource.dopus.com/t/copy-paths-of-selected-files-to-clipboard/4738/4 "2007-09-20T16:06:50Z")

</div>

This is exactly what I mean

Thanks!
