%CurrentClipboard% only stores the last of multiple lines


ich have a macro that gets filenames from an App called LEAP. It is basically a Explorer with better tagging capabilities. When I want to manipulate multiple files with KM, eg. add Tags, the easiest way is to mark them and press CMD-C. When I paste that in a text document, I get the full path of all files. Perfect.

However, when I use %CurrentClipboard%, it only safes the last line. I can even reproduce it. I have a macro that copies all the path names and uses "Paste" to past it in a text file. This works and all lines are there. And then in Pastes %CurrentClipboard% into the same document and only the last line will be pasted.

This is the macro to reproduce the problem:

And here is the result:

I ave no clue what I am doing wrong and I have the feeling that this worked before. Could it be a bug? Any help is highly appreciated (Latest KM, latest OSX)

Thank you,

Hey Julian,

Using Leap 3.6.2.

C does NOT copy anything at all here...

Correction – what's copied WON'T paste into BBEdit.

It will paste into TextEdit as files.

Forcing the clipboard to paste as plain text will only paste the last one.

(The only things on the clipboard are file-specifications.)

You should probably make a feature request to the developer. (I'm frankly shocked there's no explicit method of copying paths to the clipboard.)

Nevertheless there is a way using ASObjC (thanks to Shane Stanley).


Execute AppleScript { Text Script }.kmmacros (2.3 KB)


Hi, and thank you for your quick and helpful answer. Now that I understand the problem and with your script, I am pretty sure that I get it to work. Leap is not really actively maintained and lacks a lot of features, but it is still better than all other tag browser I tried. And I managed to work around most limitations with the help of KM.

You are right, when I past into TextEdit in Rich Text Mode, it will copy the files into the document. I just never tried it that way. In Plain Text Mode, it just copies path and filename and that usually always worked for me. Only this time I needed multiple files and wanted to loop through them and it never worked. Also KM was able to past the pathnames there, as long as they did not go through the variable, so I did not really wonder. So it looks like it is a feature of the app you are pasting into, if it can handle it that way. It even worked with a KM comment field :smile:

Thank you,

###Chris, thanks for sharing this great script/macro.

I have embellished it a bit, to check for no files on clipboard, and provide option to copy list of file URLs to clipboard:

###EDIT: Update Macro Name and Prompts
Sun, Jan 17, 2016 at 9:12 PM
Macro returns File Paths, NOT File URLs, as originally stated.

###[FILES] Get List of File Paths on Clipboard V2.1

[FILES] Get List of File Paths on Clipboard V2.1.kmmacros (7.2 KB)

###Here's the modified script

use framework "Foundation"
use scripting additions

-- Get the pasteboard
set pb to current application's NSPasteboard's generalPasteboard()
-- Get its file-only URLs
set theURLs to pb's readObjectsForClasses:{current application's class "NSURL"} options:{NSPasteboardURLReadingFileURLsOnlyKey:true}
-- Convert them all to POSIX paths
set thePosixPaths to theURLs's valueForKey:"path"

set AppleScript's text item delimiters to linefeed
set PosixPathsStr to (thePosixPaths as list) as text

if (PosixPathsStr = "") then
	set resultStr to "[NONE]"
	set resultStr to PosixPathsStr
end if

return resultStr