Last active
August 29, 2015 14:13
-
-
Save DrLulz/3fe69fff75c56c72971d to your computer and use it in GitHub Desktop.
Merge selected rows in OmniOutliner. Copies selected rows below the first into the first then deletes copied rows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell front document of application "OmniOutliner" | |
if (count of selected rows) < 2 then | |
display dialog "Select rows to merge." buttons "Cancel" default button "Cancel" | |
end if | |
set row_start to (index of first selected row) --skip non-selected rows | |
set row_end to (index of last selected row) --record last row for deletion | |
repeat with n from 1 to (count of selected rows) --# of rows selected | |
set row_one to text of cells of first selected row --make list from first row | |
set row_c to 1 --change to 0 to include notes | |
repeat with i from 1 to count row_one --# of items (columns) in first row | |
set row_c to row_c + 1 | |
if n > 1 then | |
set row_copy to text of cells of row (n + row_start - 1) --make list from next row | |
set {l1, l2} to {row_one, row_copy} --merge list items | |
set newlist to {} | |
repeat with i from 1 to (count l1) | |
set end of newlist to ((item i of l1) as text) & " " & item i of l2 | |
end repeat | |
set value of cell row_c of first selected row to item row_c of newlist --insert merged items | |
if row_c is (count row_one) then exit repeat --stop at last column | |
end if | |
end repeat | |
end repeat | |
delete (rows (row_start + 1) thru (row_end)) | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment