Move to Things

Posted by agiletortoise, Last update 7 months ago

Send text on selected lines to Things as new tasks in the Inbox, removing the lines from draft. I use to this migrate tasks I created in Drafts to Things for further processing.

If there is no text selection, the current line is moved to Things. If multiple lines are selected, they are all moved as individual tasks.


  • script

    const list = "Inbox"
    // get information
    const [st,len] = editor.getSelectedLineRange()
    let selectedText = editor.getTextInRange(st, len)
    let lines = selectedText.split("\n")
    let todos = []
    // loop over lines, adding non-blank lines as todos
    // also clean up line, removing any list/task prefix
    for (line of lines) {
    	let trimmedLine = line.trim() // remove whitespace
    	trimmedLine = trimmedLine.replace(/^[-\* \[\]x]+/, "")
    	if (trimmedLine.length == 0) { // skip blank lines
    	let todo = TJSTodo.create()
    	todo.title = trimmedLine
    	todo.list = list
    if (todos.length > 0) {
    	// create Things object to create URL
    	const container = TJSContainer.create(todos)
    	var cb = CallbackURL.create()
    	cb.baseURL = container.url
    	if ( {
    		console.log("Todos created in Things")
    		editor.setTextInRange(st, len, "")
    		editor.setSelectedRange(st, 0)
    	else {
    else { // no todos to create
    	alert("No todos found")


  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.