Simple clipboard tool

Hi team,

I would like your valuable advice for a very simple task.

So, I want to create a script that gets the contents of the clipboard as paragraphs, gets rids of the empty lines, then it pastes only the first paragraph and saves the rest of the paragraphs (without the first line) in the clipboard.

So far I developed the following, but cannot be applied the second time. Any help please?

Try something like this:


set myText to paragraphs of (the clipboard)
set filteredText to {}
repeat with thisGraph in myText
	if thisGraph is not in {"", " ", tab} then set the end of filteredText to thisGraph as item
end repeat

set textToPaste to item 1 of filteredText as text
set AppleScript's text item delimiters to {return}
set the clipboard to the rest of filteredText as text
----paste textToPaste here---

Awesome! Thank you, it worked!

I just added a message as well:

	
	set myText to paragraphs of (the clipboard)
	set filteredText to {}
	repeat with thisGraph in myText
		if thisGraph is not in {"", " ", tab} then set the end of filteredText to thisGraph as item
		
	end repeat
	
	if filteredText = {} or length of filteredText < 1 then
		display dialog "The clipboard is empty." buttons {"OK"}
	else
		set textToPaste to item 1 of filteredText as text
		set AppleScript's text item delimiters to {return}
		set the clipboard to the rest of filteredText as text
		tell application "System Events" to keystroke (textToPaste as text)
	end if