FileTypes

The FileTypes class provides the means for identifying files by their kind, type identifier, or display name.

Common FileTypes

Data and information are often shared as files in standard formats such as plain or rich text (txt, rtf), images (TIFF, JPEG, PNG, etc.), and as organized data archives (JSON, XML, and Property Lists). To enable these types of files to be used with Omni Automation scripts, they have been assigned the following default class property values:

To create an instance of one of these generalized types, append the class property name to the FileType class name, like this:

FileType Instance Properties

Every instance of a FileType has read-only properties whose values can be accessed via a script:

You can use these instance properties to return information for any file type:

FileType.binaryPropertyList.displayName //-> binary property list FileType.binaryPropertyList.identifier //-> com.apple.binary-property-list FileType.binaryPropertyList.pathExtensions //-> ["plist"]

Creating a FileType Instance

Instances of the FileType class are created using the standard JavaScript new constructor. Simply provide the corresponding identifier to the desired file type:

fType = new FileType("com.omnigroup.omnigraffle.graffle") console.log(fType.displayName) console.log(fType.pathExtensions)
fType = new FileType("public.plain-text") console.log(fType.displayName) console.log(fType.pathExtensions)

Checking a FileType Instance

On occasion your scripts may need to compare instances of file types. The conformsTo(…) method of the FileType class, when called upon an instance of a file type, will return a boolean value of true if the provided comparison file type instance is the same or a more specific version of the provided comparison file type:

For example, a PNG file type is a more specific variant of the image file type, whereas a PNG file type does not match and is not a more specific variant of the plain text file type:

FileType.png.conformsTo(FileType.image) FileType.png.conformsTo(FileType.plainText)

Folder FileType

On occasion, such as when using a FileSaver, you may need to create an instance of the FileType class that represents a folder.

folderFileType = new FileType("public.folder")

Application Specific FileTypes OmniGraffle-iOS-256 OmniOutliner-iOS-256 OmniFocus-iOS-256 OmniPlan-iOS-256    <-- TAP|CLICK>

Every Omni application that supports Omni Automation has document types specific to that application. These document types are grouped as either readable or writeable by the host application.

The values of the global FileType class properties readableTypes and writableTypes provide the list of types that can be read/written by any document in the app.

IMPORTANT: The value of the writableTypes property of the FileType class is not the same as the vaule of the writableTypes property of the Document class.

The value of the The value of the writableTypes property of the FileType class is an array of FileType objects.

The writableTypes property of the Document class is an array of type identifier strings that are used when saving the current document, usually in conjunction with the FileSaver class.

The application-specific list shown below includes both FileType.writableTypes and document.writableTypes lists:

The following scripts can be used in any of the Omni suite of applications for gathering information about each file type:

FileType.readableTypes.forEach(function(fType){ console.log('NAME: ' + fType.displayName) console.log('IDENTIFIER: ' + fType.identifier) console.log('EXTENSIONS: ' + fType.pathExtensions) console.log('----------------------------') })
FileType.writableTypes.forEach(function(fType){ console.log('NAME: ' + fType.displayName) console.log('IDENTIFIER: ' + fType.identifier) console.log('EXTENSIONS: ' + fType.pathExtensions) console.log('----------------------------') })

OmniGraffle-iOS-256(FileType Class) Readable Types: OmniGraffle

FileType.readableTypes.map(function(fType){return fType.displayName})
FileType.readableTypes.map(function(fType){return fType.identifier})
FileType.readableTypes.map(function(fType){return fType.pathExtensions})

OmniGraffle-iOS-256(FileType Class) Writeable Types: OmniGraffle

FileType.writableTypes.map(function(fType){return fType.displayName})
FileType.writableTypes.map(function(fType){return fType.identifier})
FileType.writableTypes.map(function(fType){return fType.pathExtensions})

OmniGraffle-iOS-256(Document Class) Writeable Types: OmniGraffle

types = document.writableTypes.map((type)=>{ return "\"" + type + "\""}) types = "[" + types.join(",\n") + "]" console.log(types)
"com.omnigroup.omnigraffle.graffle" "com.omnigroup.omnigraffle.graffle-package" "com.adobe.pdf" "public.tiff" "public.png" "com.compuserve.gif" "public.jpeg" "public.svg-image" "com.adobe.encapsulated-postscript" "com.omnigroup.omnigraffle.HTMLExport" "com.omnigroup.omnioutliner.oo3" "com.microsoft.bmp" "com.omnigroup.foreign-types.ms-visio.xml" "com.adobe.photoshop-image" "com.omnigroup.omnigraffle.diagramstyle" "com.omnigroup.omnigraffle.diagramstyle-package" "com.omnigroup.omnigraffle.template" "com.omnigroup.omnigraffle.template-package" "com.omnigroup.omnigraffle.gstencil" "com.omnigroup.omnigraffle.gstencil-package"

OmniOutliner-iOS-256(FileType Class) Readable Types: OmniOutliner

FileType.readableTypes.map(function(fType){return fType.displayName})
FileType.readableTypes.map(function(fType){return fType.identifier})
content = FileType.readableTypes.map(function(fType){return String("[\"" + fType.pathExtensions + "\"]")});console.log("[" + content + "]")

OmniOutliner-iOS-256(FileType Class) Writeable Types: OmniOutliner

FileType.writableTypes.map(function(fType){return fType.displayName})
FileType.writableTypes.map(function(fType){return fType.identifier})
FileType.writableTypes.map(function(fType){return fType.pathExtensions})

OmniOutliner-iOS-256(Document Class) Writeable Types: OmniOutliner

"com.omnigroup.omnioutliner.xmlooutline" "com.omnigroup.omnioutliner.ooutline" "com.omnigroup.omnioutliner.oooutline" "com.omnigroup.omnioutliner.xmlooutline-package" "com.omnigroup.omnioutliner.otemplate" "com.omnigroup.omnioutliner.otemplate-package" "com.omnigroup.omnioutliner.oo3" "com.omnigroup.omnioutliner.oo3-package" "com.omnigroup.omnioutliner.oo3template" "com.omnigroup.omnioutliner.oo3template-package" "org.opml.opml" "com.apple.news.opml" "org.opml.opmltemplate" "public.rtf" "public.plain-text" "com.apple.rtfd" "com.omnigroup.word.openxml.indented.Microsoft Word (indented)" "com.omnigroup.word.openxml.outline.Microsoft Word (outline)" "com.omnigroup.OmniOutliner.SimpleHTMLExport.HTML" "org.openxmlformats.presentationml.presentation.PowerPoint 2012 Format (pptx)" "com.omnigroup.OmniOutliner.OO3HTMLExport.OO3HTMLDynamic" "com.omnigroup.OmniOutliner.HTMLExport.HTMLDynamic" "com.microsoft.excel.openxml.document.Excel 2010 Format (xlsx)" "com.omnigroup.OmniOutliner.MacAppStore.CSVExport.CSV"

omnifocus-ios-256(FileType Class) Readable Types: OmniFocus

FileType.readableTypes.map(function(fType){return fType.displayName})
FileType.readableTypes.map(function(fType){return fType.identifier})
content = FileType.readableTypes.map(function(fType){return String("[\"" + fType.pathExtensions + "\"]")});console.log("[" + content + "]")

omnifocus-ios-256(FileType Class) Writeable Types: OmniFocus

FileType.writableTypes.map(function(fType){return fType.displayName})
FileType.writableTypes.map(function(fType){return fType.identifier})
FileType.writableTypes.map(function(fType){return fType.pathExtensions})

omnifocus-ios-256(Document Class) Writeable Types: OmniFocus

"com.omnigroup.omnifocus.filetype.ofocus" "com.omnigroup.omnifocus2.export-filetype.plain-text" "com.omnigroup.omnifocus2.export-filetype.html" "com.omnigroup.omnifocus2.export-filetype.comma-separated-values" "com.omnigroup.omnifocus2.export-filetype.comma-separated-values-unicode" "com.omnigroup.omnifocus.filetype.ofocus-backup"

omniplan-ios-256(FileType Class) Readable Types: OmniPlan

FileType.readableTypes.map(function(fType){return fType.displayName})
FileType.readableTypes.map(function(fType){return fType.identifier})
FileType.readableTypes.map(function(fType){return fType.pathExtensions})

omniplan-ios-256(FileType Class) Writeable Types: OmniPlan

FileType.writableTypes.map(function(fType){return fType.displayName})
FileType.writableTypes.map(function(fType){return fType.identifier})
FileType.writableTypes.map(function(fType){return fType.pathExtensions})

omniplan-ios-256(Document Class) Writeable Types: OmniPlan

"com.omnigroup.omniplan2.planfile-zip" "com.omnigroup.omniplan2.planfile" "com.apple.ical.ics" "public.comma-separated-values-text" "com.microsoft.mpp" "com.microsoft.project.mspdi" "public.png" "com.adobe.pdf" "public.tiff" "public.jpeg" "com.omnigroup.omnioutliner.oo3" "com.omnigroup.omnigraffle.graffle"
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER