Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImSingee/6f0b773756421239e7cb50126a9c5d89 to your computer and use it in GitHub Desktop.
Save ImSingee/6f0b773756421239e7cb50126a9c5d89 to your computer and use it in GitHub Desktop.
OmniFocus-设定连续的截止时间,将选中的任务批量递增的设置截止时间;ADD_DAYS 用于配置每次加几天、PERIOD_TIMES 用于配置几个任务后进行增加。选中的首个任务的截止时间是「今天 + ADD_DAYS 天的 23:59」,即 ADD_DAYS 设置为 1 则首个任务的截止时间是明天的 23:59
on run {}
set ADD_DAYS to 1
set PERIOD_TIMES to 1
set _time to 0
set _date to current date
repeat with _action in my selectedActions()
if _time mod PERIOD_TIMES is equal to 0 then
set _date to calculateDate(_date, ADD_DAYS)
end if
set _time to (_time + 1)
my processAction(_action, _date)
end repeat
tell application "OmniFocus"
tell default document
compact
end tell
end tell
end run
on selectedActions()
tell application "OmniFocus"
return my filterValues(my selectedValues(), {inbox task, task, available task, remaining task})
end tell
end selectedActions
on selectedValues()
tell application "OmniFocus"
return value of selected trees of content of first document window of front document
end tell
end selectedValues
on filterValues(_values, _classes)
tell application "OmniFocus"
set _result to {}
repeat with _value in _values
if _classes contains _value's class then
copy _value to end of _result
end if
end repeat
return _result
end tell
end filterValues
on processAction(_action, _date)
tell application "OmniFocus"
set _action's due date to _date
end tell
end processAction
on calculateDate(last_date, ADD_DAYS)
set day of last_date to ((last_date's day) + ADD_DAYS)
set time of last_date to (24 * 3600 - 1) -- 23:59
return last_date
end calculateDate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment