Skip to content

importoptions

new ImportOptions();

new ImportOptions(file);

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");

importOptions.file

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

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

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

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!

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

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!

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.

/*
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

When true, a sequence is imported; otherwise, an individual file is imported.

Boolean; read/write.


importOptions.canImportAs(type)

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.

ParameterTypeDescription
typeImportAsType enum.The type of file that can be imported. One of:
- ImportAsType.COMP
- ImportAsType.FOOTAGE
- ImportAsType.COMP_CROPPED_LAYERS
- ImportAsType.PROJECT

Boolean.

var io = new ImportOptions(new File("c:\\myFile.psd"));
if (io.canImportAs(ImportAsType.COMP)) {
io.importAs = ImportAsType.COMP;
}

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!

Reports whether the file object is numbered, i.e. file name has a digit.

ParameterTypeDescription
fileExtendscript File objectThe file to check

Object, containing 2 keys:

  • isNumbered: Boolean; wether the file name contains any digit,
  • num: Integer; a number found in file name. Returns 0 when isNumbered is false.
var importOptions = new ImportOptions();
importOptions.isFileNameNumbered('image.png'); // "isNumbered": false, "num": 0
importOptions.isFileNameNumbered('003image.png'); // "isNumbered": true, "num": 3
importOptions.isFileNameNumbered('ima0102ge.png'); // "isNumbered": true, "num": 102
importOptions.isFileNameNumbered('image0120.png'); // "isNumbered": true, "num": 120