Code to create/append text file

I couldn´t find an example in the forum. The code should append the clipboard contents from a previous Clipboard Copy
into a text file, "sample.rtf", (or if rtf is problematic, txt will also do) in N:\RTFs\sample.

So starting with an empty file, the first run would insert the paths, & every new run would append more paths. The button
is intended to make an "inspection" list of various folders, which i can compare with my files at home, sort of "syncing".

I don't know how to append new text to an existing file, but what you can do is collecting everything you want to have in the Textfile in Clipboard.
I'm using leo's tool Setclip.exe for this:
Here's the basic Code for collecting the full paths of all selected files in Clipboard which you can change to your needs (e.g. Select ALL in the second line):

@runmode hide "[Path to Setclip.exe]\SetClip.exe" -a {filepath|noterm}
Before you start your Collection you should clear the Clipboard with this (put it to the RMB of a 3-way Button):

@nodeselect @runmode hide "[Path to Setclip.exe]\SetClip.exe" -e

Yeah, it works so far. I used setclip a while ago for collecting items, but switched to use the collections for that task.
Only problem is, it won´t work over several sessions, & i have to open the file manually (ok, i can add that line to the code
& save this step) & paste it in, or have to use multiple textfiles.

If you go to:

And download the free nircmd utility, you can do this with a couple Opus buttons set in MSDOS mode. Actually on my Windows 7 machine it doesn't seem to matter if the Opus buttons are in MSDOS mode or Standard Function (Opus or external).

Anyway, if you don't put nircmd in a folder that's defined in the Windows %PATH% environment variable, you'll have to include the full path to it in your buttons.

Button 1 creates a new text file named info.txt (overwriting any previous info.txt file) and copies the text in the clipboard to it.

nircmd.exe clipboard writefile "D:\my folder\info.txt"

The next button appends clipboard text to the info.txt file.

nircmd.exe clipboard addfile "D:\my folder\info.txt"

Yeah John, that's the smart way to do it.

I didn't need to set the Button to MSDOS-Mode. It's simply working.

I have Nirtools already installed. But it replaces the contents with the current session, not appending anything. If i have

E:\my folder\file01
E:\my folder\file02
E:\my folder\file03

in the first session, adding

E:\my folder\file04
E:\my folder\file05
E:\my folder\file06

will overwrite the first three instead of making the list having all six entries.

You need to use the second Command John provided to append the text, not the first command a second time.

Ooops, that´s why. I had confused the two commands in the 3-Button. Now it works.
Thank you both. Note: don´t try out button codes while watching a movie. :smiley: