importoptions
ImportOptions object
Section titled “ImportOptions object”new ImportOptions();
new ImportOptions(file);
Description
Section titled “Description”The ImportOptions object encapsulates the options used to import a file with the Project.importFile() methods.
The constructor takes an optional parameter, an Extendscript File object for the file.
If it is not supplied, you must explicitly set the value of the file
attribute before using the object with the importFile
method. For example:
new ImportOptions().file = new File("myfile.psd");
Attributes
Section titled “Attributes”ImportOptions.file
Section titled “ImportOptions.file”importOptions.file
Description
Section titled “Description”The file to be imported. If a file is set in the constructor, you can access it through this attribute.
Extendscript File object; read/write.
ImportOptions.forceAlphabetical
Section titled “ImportOptions.forceAlphabetical”importOptions.forceAlphabetical
Description
Section titled “Description”When true
, has the same effect as setting the “Force alphabetical order” option in the File > Import > File dialog box.
Boolean; read/write.
ImportOptions.importAs
Section titled “ImportOptions.importAs”importOptions.importAs
Description
Section titled “Description”The type of object for which the imported file is to be the source. Before setting, use canImportAs to check that a given file can be imported as the source of the given object type.
An ImportAsType
enumerated value; read/write. One of:
ImportAsType.COMP_CROPPED_LAYERS
ImportAsType.FOOTAGE
ImportAsType.COMP
ImportAsType.PROJECT
ImportOptions.rangeEnd
Section titled “ImportOptions.rangeEnd”importOptions.rangeEnd
This method/property is officially undocumented and was found via research. The information here may be inaccurate, and this whole method/property may disappear or stop working some point. Please contribute if you have more information on it!
Description
Section titled “Description”Sets the end clipping range of the sequence, that is going to be imported.
- Creates ‘missing frames’ (video-bards) if the
rangeEnd
exceeds the duration of the sequence to be imported. - Has no effect if sequence is set to
false
. - Throws an exception if forceAlphabetical is set to
true
. - Throws an exception if
rangeEnd
is less then rangeStart and resets the range to include all the files.
Integer; read/write.
ImportOptions.rangeStart
Section titled “ImportOptions.rangeStart”importOptions.rangeStart
This method/property is officially undocumented and was found via research. The information here may be inaccurate, and this whole method/property may disappear or stop working some point. Please contribute if you have more information on it!
Description
Section titled “Description”Sets the start clipping range of the sequence, that is going to be imported.
- Has no effect if sequence is set to
false
. - Throws an exception if forceAlphabetical is set to
true
. - Throws an exception if rangeEnd value is 0.
- Throws an exception if
rangeStart
is greater then rangeEnd and resets the range to include all the files.
Integer; read/write.
Example
Section titled “Example”/* Import 20 frames of the sequence, starting at frame 10 and ending at frame 30 */var mySequence = '~/Desktop/sequence/image_000.png';
var importOptions = new ImportOptions();importOptions.file = new File(mySequence);importOptions.sequence = true;importOptions.forceAlphabetical = false;importOptions.rangeStart = 10;importOptions.rangeEnd = 30;
var item = app.project.importFile(importOptions);
ImportOptions.sequence
Section titled “ImportOptions.sequence”importOptions.sequence
Description
Section titled “Description”When true
, a sequence is imported; otherwise, an individual file is imported.
Boolean; read/write.
Methods
Section titled “Methods”ImportOptions.canImportAs()
Section titled “ImportOptions.canImportAs()”importOptions.canImportAs(type)
Description
Section titled “Description”Reports whether the file can be imported as the source of a particular object type. If this method returns true
, you can set the given type as the value of the importAs attribute.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
type | ImportAsType enum. | The type of file that can be imported. One of: |
- ImportAsType.COMP | ||
- ImportAsType.FOOTAGE | ||
- ImportAsType.COMP_CROPPED_LAYERS | ||
- ImportAsType.PROJECT |
Returns
Section titled “Returns”Boolean.
Example
Section titled “Example”var io = new ImportOptions(new File("c:\\myFile.psd"));if (io.canImportAs(ImportAsType.COMP)) { io.importAs = ImportAsType.COMP;}
ImportOptions.isFileNameNumbered()
Section titled “ImportOptions.isFileNameNumbered()”importOptions.isFileNameNumbered(file)
This method/property is officially undocumented and was found via research. The information here may be inaccurate, and this whole method/property may disappear or stop working some point. Please contribute if you have more information on it!
Description
Section titled “Description”Reports whether the file object is numbered, i.e. file name has a digit.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
file | Extendscript File object | The file to check |
Returns
Section titled “Returns”Object, containing 2 keys:
isNumbered
: Boolean; wether the file name contains any digit,num
: Integer; a number found in file name. Returns 0 whenisNumbered
isfalse
.
Example
Section titled “Example”var importOptions = new ImportOptions();importOptions.isFileNameNumbered('image.png'); // "isNumbered": false, "num": 0importOptions.isFileNameNumbered('003image.png'); // "isNumbered": true, "num": 3importOptions.isFileNameNumbered('ima0102ge.png'); // "isNumbered": true, "num": 102importOptions.isFileNameNumbered('image0120.png'); // "isNumbered": true, "num": 120