Clipboard COPYNAMES - add quotes only when there are spaces?

Hi, I was wondering if there is a way to get the "Clipboard COPYNAMES" command to quote a path with a space, while not quoting a path that doesn't contain a space. Right now, I'm using "Clipboard COPYNAMES=short" to accomplish passing paths with and without spaces, but would like to pass the long pathnames. If the pathname has a space, it breaks the program I am passing the path to. For example, instead of placing this to the clipboard:

D:\Downloads\file.txt
D:\Downloads\file 1.txt

I would like to place this on the clipboard:

D:\Downloads\file.txt
"D:\Downloads\file 1.txt"

I searched the forum and couldn't find anything that helped me. Thanks in advance for any advice.

This command seems to do the trick:

Clipboard COPYNAMES REGEXP "(.* .*)" ""\1""

Hi leo!

Thank you so much for the fast response! Your regular expression is working great! I need to get a better handle on using them because they are quite powerful. This post and all the others you've made really help a regex newbie like me. Thanks again and have a great day! :thumbsup:

A post was split to a new topic: Clipboard COPYNAMES - Capturing with regex