curtdusoleil
curtdusoleil

Reputation: 39

Setting a file path as text to clipboard in LUA

I am a total noob to LUA.

I need a script that will just copy a file path as text to the clipboard. That's it. I absolutely cannot figure it out. I keep getting the error:

attempt to call a nil value (global 'set_clipboard')

Here is the file path I am trying to copy to the clipboard:

D:_Google Drive_Acting\VO\Room Tone\roomtone.wav

This must be a simple script, right?

Upvotes: 3

Views: 2026

Answers (2)

tonypdmtr
tonypdmtr

Reputation: 3225

For Windows you can do this:

filename = 'my_filename.txt'
io.popen('clip','w'):write(filename):close()

Upvotes: 3

lhf
lhf

Reputation: 72312

There is no built-in function for that.

In Mac OS, you can do this

function set_clipboard(text)
    io.popen('pbcopy','w'):write(text):close()
end

Apparently, in Windows you can use clip instead of pbcopy. I don't know about Linux.

Upvotes: 2

Related Questions