Editorial Workflows

Manage Tags...

unlisted workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Manages tags of other workflows (rename/delete tags, add tag to multiple workflows at once)

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Show Alert ?
Title
Manage Workflow Tags
Message
Button 1
Rename Tag...
Output Value
Rename
Button 2
Delete Tag...
Output Value
Delete
Button 3
Batch Add...
Output Value
Batch
Show Cancel Button
ON
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Rename
List Workflow Tags ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
names = []
tags = []
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		tags += wf_info.get('tags', [])

if len(tags) == 0:
	import console
	console.hud_alert('No Tags Found', 'error')
	workflow.stop()
else:
	unique_tags = sorted(set(tags))
	workflow.set_output('\n'.join(unique_tags))
Select from List ?
Title
Rename Tag
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Set Variable ?
Variable Name
Old
Value
Input
Request Text Input ?
Title
New Tag Name
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

old_tag = workflow.get_variable('Old')
new_tag = workflow.get_input()

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		tags = wf_info.get('tags', [])
		if old_tag in tags:
			replacement = [tag for tag in tags if tag != old_tag] + [new_tag]
			wf_info['tags'] = replacement

with open(wf_path, 'w') as f:
	json.dump(wf_data, f)
editor.reload_workflows()
Show HUD ?
HUD Text
Tag Renamed
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Delete
List Workflow Tags ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
names = []
tags = []
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		tags += wf_info.get('tags', [])

if len(tags) == 0:
	import console
	console.hud_alert('No Tags Found', 'error')
	workflow.stop()
else:
	unique_tags = sorted(set(tags))
	workflow.set_output('\n'.join(unique_tags))
Select from List ?
Title
List (Lines)
Input
Multiple Selection
OFF
Show in Popover
OFF
Show Alert ?
Title
Delete Tag?
Message
Do you really want to delete the tag 'Input'?
Button 1
Delete
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

deleted_tag = workflow.get_input()

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		tags = wf_info.get('tags', [])
		if deleted_tag in tags:
			replacement = [tag for tag in tags if tag != deleted_tag]
			wf_info['tags'] = replacement

with open(wf_path, 'w') as f:
	json.dump(wf_data, f)
editor.reload_workflows()
Show HUD ?
HUD Text
Tag Deleted
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Batch
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
names = []
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		names.append(wf_info.get('title', ''))

workflow.set_output('\n'.join(names))
Select from List ?
Title
Add tag to...
List (Lines)
Input
Multiple Selection
ON
Show in Popover
OFF
Set Variable ?
Variable Name
Selected Workflows
Value
Input
Request Text Input ?
Title
Add Tag
Initial Text
  • Single Line
  • Multiple Lines
Keyboard Options:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
import os
import json

selected_titles = workflow.get_variable('Selected Workflows').split('\n')
tag_to_add = workflow.get_input()

wf_path = os.path.join(editor.get_workflows_path(), 'Commands.edcmd')
with open(wf_path, 'r') as f:
	wf_data = json.load(f)
	for wf_info in wf_data:
		name = wf_info.get('title', '')
		if name in selected_titles:
			tags = wf_info.get('tags', [])
			if not tag_to_add in tags:
				replacement = tags + [tag_to_add]
				wf_info['tags'] = replacement

with open(wf_path, 'w') as f:
	json.dump(wf_data, f)
editor.reload_workflows()
Generate Text ?
Text
Selected Workflows
Count ?
What to Count:
  • Words
  • Sentences
  • Lines
  • Characters
Show HUD ?
HUD Text
Tag Added to Input Workflows
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"
…End If