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.
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)
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
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]"
else
set resultStr to PosixPathsStr
end if
return resultStr