"Pasting" file contents

Hello. Is there a way to paste contents of certain file (ex., C:\1.txt) as new .txt files in {s}?

i want to copy file's contents. for ex., file 1.txt contains this lines:
Directory Opus 1
Directory Opus 2
Directory Opus 3
...
Directory Opus 1000

i want to create 1000 new .txt files, a copy of "FileType NEW=.txt FROMCLIPBOARD" command, but from file, not clipboard...

the basis of this question is here: DL from YT
may be there is a simpler and smarter way to paste video names from playlist directly to folder as empty .txt files?

This will create an empty text file for each line in the clipboard:

(I think both Lxp and I misinterpreted what you wanted to do in the other thread, but it's much clearer now.)

i saw this thread. this is not that i need. I can only output video names to .txt file (let's say TEMP file), not to clipboard. Thus, using Paste empty file list, i need to open my .txt (temp) file, copy all its contents and call the script. too many actions...

That's why I requested help in this thread, combining its script with "FileType NEW=.txt FROMCLIPBOARD" command would be the best solution.

Try

// https://resource.dopus.com/t/pasting-file-contents/44783

function OnClick(clickData) {
    var cmd = clickData.func.command;
    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(), 'utf8'));
    cmd.RunCommand('FileType NEW=.txt FROMCLIPBOARD');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
	<label>44783</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/pasting-file-contents/44783</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</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;utf8&apos;));</instruction>
		<instruction>    cmd.RunCommand(&apos;FileType NEW=.txt FROMCLIPBOARD&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

Thank you too much. This code works better for me:

CopyContent c:\1.txt
FileType NEW=.txt FROMCLIPBOARD

Is there a way to combine MS-DOS button

"C:\Program Files\yt-dlp.exe" -i  --get-filename --flat-playlist  -o "%%(playlist_index)s %%(title)s" {clip} >C:\1.txt

with above Dopus commands to be runnig one by one in one button? like this (but it's not working properly for me):

"C:\Program Files\yt-dlp.exe" -i  --get-filename --flat-playlist  -o "%%(playlist_index)s %%(title)s" {clip} >C:\1.txt

/home\dopusrt.exe CopyContent c:\1.txt
/home\dopusrt.exe FileType NEW=.txt FROMCLIPBOARD

???

Putting the DOS button into a user command and using this user command instead of the explicit line should work. Or put everything in a script.

1 Like

Is the 1.txt file needed after you've created the other files?

If not, you could skip the file creation/reading the file into clipboard and instead pipe the yt-dlp results into the clipboard:
yt-dlp.exe ... | clip and work directly from that.

2 Likes

Ooooooooooooh! no one has given me better advice! Thank you, Man!

That thread was about reading one file's contents out of the file and into the clipboard. It didn't involve creating files. That's partly why I was initially confused about what you wanted to do.