VCOF0004
App-Related Folders
Voice Control commands call four OmniFocus plug-ins designed to access, open, and save clipboard text into the app-related Document folders, like the local app sandboxed Documents folder, and the app’s corresponding auto-generated iCloud folder.
Scope and Syntax
Language: English (United States 🇺🇸 · Great Britain 🇬🇧 · Australia 🇦🇺 · Canada 🇨🇦) • Scope: OmniFocus
Command phrase variations (words in [brackets] are optional):
- “Open [the] Documents Folder for this Application”
- “Open [the] iCloud Folder for this Application”
- “Save Clipboard Text to [the] Documents Folder for this Application”
- “Save Clipboard Text to [the] iCloud Folder for this Application”
Downloads
Requirements: Plug-In: OmniFocus 4; Commands File: macOS
The following set of Omni Automation plug-ins that that work with any Omni application:
- Open App Documents Folder • Open the sandboxed Documents folder for the host Omni application.
- Open App iCloud Folder • Open the iCloud Documents folder for the host Omni application.
- Clipboard Text to App Documents Folder • Save the clipboard text as a file to the sandboxed Documents folder of the host Omni application.
- Clipboard Text to App iCloud Folder • Save the clipboard text as a file to the iCloud Documents folder of the host Omni application.
You can install these plug-ins and target them using voice commands.
⇩ PLUG-IN-COLLECTION • To install, place the folder containing the plug-ins in the host Omni application’s Plug-Ins folder, which is accessed from the Automation Configuration dialog summoned from the app Automation menu.
⇩ (OF 4.0) COMMANDS-FILE • The voice commands file contains four commands, one for each plug-in.
⇩ (OF 3.13) COMMANDS-FILE • The voice commands file contains four commands, one for each plug-in.
Voice Command Code
The clipboard text can be saved as "Text (plain)", "TaskPaper", "HTML", "JavaScript", or "SVG". NOTE: The corresponding file extension will automatically be appended to the provided file name.
Here’s the plug-in code for one of the Omni Automation plug-ins.
Save Clipboard Text to App iCloud Folder
/*{
"type": "action",
"targets": ["omnifocus", "omnigraffle", "omniplan", "omnioutliner"],
"author": "Otto Automator",
"identifier": "com.omni-automation.all.write-clip-text-to-app-iCloud",
"version": "1.0",
"description": "Uses a stored boomark to save the text content of the clipboard to the current application’s iCloud folder (if it exists). To remove the stored Bookmark, hold down the Control key when selecting the plug-in from the Automation menu.",
"label": "Clip Text to App iCloud Folder",
"shortLabel": "Save to App iCloud",
"paletteLabel": "Save to App iCloud",
"image": "icloud.and.arrow.up.fill"
}*/
(() => {
var credentials = new Credentials()
var serviceTitle = `${app.name} iCloud Folder`
console.log(serviceTitle)
var action = new PlugIn.Action(async function(selection, sender){
try {
// TO REMOVE BOOKMARK HOLD DOWN CONTROL KEY WHEN SELECTING PLUG-IN
if (app.controlKeyDown){
alertMessage = "Remove the stored bookmark?"
alert = new Alert("Confirmation Required", alertMessage)
alert.addOption("Remove")
alert.addOption("Cancel")
buttonIndex = await alert.show()
if (buttonIndex === 0){credentials.remove(serviceTitle)}
throw new Error("Bookmark removed")
}
// RETRIEVE BOOKMARK
var bookmark = credentials.readBookmark(serviceTitle)
// IF NO BOOKMARK, ASK FOR FOLDER
if(!bookmark){
picker = new FilePicker()
picker.folders = true
picker.multiple = false
if (Device.current.mac){
picker.message = `Please select the ${app.name} iCloud folder:`
} else {
alertTitle = "Select Folder"
alertMessage = `Close this alert and in the forthcoming picker, select ${serviceTitle}.`
await new Alert(alertTitle, alertMessage).show()
}
chosenDirectoryURLs = await picker.show()
bookmark = URL.Bookmark.fromURL(chosenDirectoryURLs[0])
credentials.writeBookmark(serviceTitle, bookmark)
bookmark = credentials.readBookmark(serviceTitle)
}
inputForm = new Form()
fileNameField = new Form.Field.String(
"fileBaseName",
"File Name",
null,
null
)
inputForm.addField(fileNameField)
fileTypes = ["Text (plain)", "TaskPaper", "HTML", "JavaScript", "SVG"]
nameExtensions = ["txt", "taskpaper", "html", "js", "svg"]
savingTypeMenu = new Form.Field.Option(
"nameExtension",
"Text File Type",
nameExtensions,
fileTypes,
nameExtensions[0]
)
inputForm.addField(savingTypeMenu)
if (Device.current.mac){
shouldOpenFileField = new Form.Field.Checkbox(
"shouldOpenFile",
"Open file in default application",
null
)
inputForm.addField(shouldOpenFileField)
}
inputForm.validate = function(formObject){
textValue = formObject.values['fileBaseName']
return (textValue && textValue.length > 0) ? true:false
}
formPrompt = `Clipboard to ${serviceTitle}`
buttonTitle = "Continue"
formObject = await inputForm.show(formPrompt, buttonTitle)
fileBaseName = formObject.values["fileBaseName"]
nameExtension = formObject.values["nameExtension"]
fileName = fileBaseName + "." + nameExtension
if (Device.current.mac){
var shouldOpenFile = formObject.values["shouldOpenFile"]
}
// RETRIEVE BOOKMARK
bookmark = credentials.readBookmark(serviceTitle)
// IF NO BOOKMARK, ASK FOR FOLDER
if(!bookmark){
picker = new FilePicker()
picker.folders = true
picker.multiple = false
if (Device.current.mac){
picker.message = `Please select the ${app.name} iCloud folder:`
} else {
alertTitle = "Select Folder"
alertMessage = `Close this alert and in the forthcoming picker, select ${serviceTitle}.`
await new Alert(alertTitle, alertMessage).show()
}
chosenDirectoryURLs = await picker.show()
bookmark = URL.Bookmark.fromURL(chosenDirectoryURLs[0])
credentials.writeBookmark(serviceTitle, bookmark)
bookmark = credentials.readBookmark(serviceTitle)
}
// RETRIEVE ACCESS TOKEN AND PERFORM ACTION WITH FOLDER
token = await bookmark.access()
iCloudFldrURL = token.url
fileURL = iCloudFldrURL.appendingPathComponent(fileName)
data = Data.fromString(Pasteboard.general.string)
wrapper = FileWrapper.withContents(fileName, data)
wrapper.write(fileURL, [FileWrapper.WritingOptions.Atomic], null)
if (Device.current.mac){
// ON macOS OPEN THE FILE
if(shouldOpenFile){fileURL.open()}
}
} catch(err){console.error(err.message)}
});
action.validate = function(selection, sender){
return (Pasteboard.general.hasStrings)
};
return action;
})();
LEGAL
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Mention of third-party websites and products is for informational purposes only and constitutes neither an endorsement nor a recommendation. OMNI-AUTOMATION.COM assumes no responsibility with regard to the selection, performance or use of information or products found at third-party websites. OMNI-AUTOMATION.COM provides this only as a convenience to our users. OMNI-AUTOMATION.COM has not tested the information found on these sites and makes no representations regarding its accuracy or reliability. There are risks inherent in the use of any information or products found on the Internet, and OMNI-AUTOMATION.COM assumes no responsibility in this regard. Please understand that a third-party site is independent from OMNI-AUTOMATION.COM and that OMNI-AUTOMATION.COM has no control over the content on that website. Please contact the vendor for additional information.