Script: Export Selected To Instapaper CSV

  • exports selected record’s URLs into an Instapaper-formatted CSV - URL,Title,,Unread,Timestamp - where Timestamp is a UNIX epoch timestamp
  • can be consumed by Instapaper or Readwise Reader.
tell application id "DNtp"
	set theCsvRecords to {"URL,Title,Selection,Folder,Timestamp\n"}
	repeat with thisRecord in (selected records)
        -- convert an AppleScript Date object to a UNIX timestamp (seconds since epoch)
        set command to "/bin/date -j -f '%A, %B %e, %Y at %I:%M:%S %p' '" & (creation date of thisRecord) & "'"
	    set command to command & " +%s"
	    set theUnixDate to do shell script command
		copy ((URL of thisRecord) & "," & "\"" & (name of thisRecord) & "\",,Unread," & theUnixDate & "\n") to end of theCsvRecords
	end repeat
	if theCsvRecords ≠ {} then
		display notification ((count items of theCsvRecords) & " Instapaper CSV records copied" as string) with title "Instapaper Records"
		set the clipboard to (theCsvRecords as string)
	end if
end tell

If I understand your code correctly, this line will always be true. Since you’re adding the headline right at the beginning of the script. I think, the condition should rather be something like
count of items of theCsvRecords > (not sure if that is even AppleScript, though)

Welcome @pmbauer

Thanks for the offering. :slight_smile:

And @chrillek is correct on this: theCSVRecords will never be an empty list.