Copy file contents to clipboard

That’s just a simple file copy which you can do via the copy command.

sorry, guys. just verified all COPY's arguments, but not found a suitable one.

What’s this got to do with “copy file contents to clipboard” from 8 years ago? The clipboard isn’t involved if you’re just trying to make a second copy of a file somewhere.

Please start new threads for new questions. I’ve had to ask a few times now.

It would only include the first file, and only if it's a text file.

I just tried it and it still works OK today.

it seemed to me that this topic is the closest to my question. very close...

It's really not. You don't want to do anything to the clipboard. You want to copy a file from one place to another. Please start a new thread if you want help with that.

abcd.txt (7.6 KB)
Copy Content.dcf (988 Bytes)
Here is my test file and button it's still not work here.

The FileSystemObject can't handle your file's encoding.

This might work better:

Or use this script:

// https://resource.dopus.com/t/copy-file-contents-to-clipboard/21051

function OnClick(clickData) {
  var tab = clickData.func.sourcetab;
  if (tab.selected_files.count == 0) return;
  var stt = DOpus.Create().StringTools();
  DOpus.SetClip(stt.Decode(tab.selected_files(0).Open().Read(), 'auto'));
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
	<label>21051</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/copy-file-contents-to-clipboard/21051</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>  var tab = clickData.func.sourcetab;</instruction>
		<instruction>  if (tab.selected_files.count == 0) return;</instruction>
		<instruction>  var stt = DOpus.Create().StringTools();</instruction>
		<instruction>  DOpus.SetClip(stt.Decode(tab.selected_files(0).Open().Read(), &apos;auto&apos;));</instruction>
		<instruction>}</instruction>
	</function>
</button>
1 Like

Its not worked for me.

image

@khalidhosain @galaxyhub

The script has always worked here. Try replacing auto with utf-16-le. Maybe your system locale settings somehow confuse the StringTools.

1 Like

lol - that yields chinese text, using utf-8 works. Many thanks.

1 Like

Thank you so much, utf-8 works

// https://resource.dopus.com/t/copy-file-contents-to-clipboard/21051

function OnClick(clickData) {
  var tab = clickData.func.sourcetab;
  if (tab.selected_files.count == 0) return;
  var stt = DOpus.Create().StringTools();
  DOpus.SetClip(stt.Decode(tab.selected_files(0).Open().Read(), 'utf-8'));
}

This is works for me. Thank you