The built-in clipboard support only handles images and plain text for that type of thing.
If there's a utility with a command line that can paste rich text into a new .rtf (or .md) file, or a way to make pandoc read from the clipboard directly, then that would be easy to automate from within Opus, but there's no understanding of RTF clipboard data built-in.
I created (using ■■■■■■■) something that works in powershell, but I don't want to create a separate PS1 file.
What I want to do on the fly is: create this file in the sourcefolder using Dopus, then execute this file. And then delete the file.
But I don't know how to paste the code into the file. The code contains double and single quotes and multiple lines and I don't know how to handle that with Dopus.
I guess quotes can be escaped, but I can't get it to work.
// Dummy code
// 1. Set variable for temp file
set ps1file="{sourcepath}{file|noext}.ps1
// 2. Set varable with the complete code I need to run
set file_content="this is multiline
content 'using single' and "double quotes" and
this is the code I want to run in {sourcepath}"
// 3. Create a temporary file with this content
echo %file_content% >> %ps1file%
// 4. Execute file
powershell.exe %ps1file%
//5. Delete temp file
Delete FORCE QUIET %ps1file%
Let's say the code is this:
# Demo.ps1
# Variabelen
$naam = "Bart"
$leeftijd = 42
$map = "C:\Temp"
# Single quotes: letterlijk weergeven
Write-Host 'Hallo $naam, 'je bent' $leeftijd jaar oud.'
# Output: Hallo $naam, 'je bent' $leeftijd jaar oud.
# Double quotes: variabelen worden ingevuld (interpolatie)
Write-Host "Hallo $naam, je bent $leeftijd jaar oud."
# Output: Hallo Bart, je bent 42 jaar oud.
# Strings samenplakken met +
Write-Host "Je bestanden staan in " + $map
# Of interpoleren in één keer
Write-Host "Je bestanden staan in $map"
# Curly braces voor veiligheid bij plakken
Write-Host "Volgende jaar ben je $($leeftijd + 1)"
# Bestandsnaam bouwen met variabelen
$bestandsNaam = "$naam-log-$leeftijd.txt"
Write-Host "Bestandsnaam wordt: $bestandsNaam"