Ep. 13 importAFile Free Function Friday
Welcome to Free Function Friday episode 13. This week we assemble a simple function that condenses the file importing process into one easy function call. To do this with ExtendScript normally you have to deal with a multistep process, by setting up an import options object then supplying that object to the importFile method itself. Now this really is decently simple build, so we are gonna go over other ExtendScript code so you can see how this function can be used. We’ll go over how to access a folder on your harddrive and how to retrieve the files from that folder. Once we are finished building that I will show you how to make a small modification and have it grab only specific files types just by adding a few more lines to our original code. This overview will hopefully help you learn a few other areas of ExtendScript. Once you know the fundamentals of accessing a folder on your computer, it will hopefully help open the door for you for many more scripting options.
There is however one requirement for allowing scripts to access the os, and it is that you have the Read/Write preference turned on in After Effects. I failed to mention this in the video, but this snippet taken from the After Effects Help / Scripts online help explains how to turn that option on manually.
Note: By default scripts are not allowed to write files or send or receive communication over a network. To allow scripts to write files and communicate over a network, choose Edit > Preferences > General (Windows) or After Effects > Preferences > General (Mac OS), and select the Allow Scripts To Write Files And Access Network option.
If you haven’t done so already there is a Free Function Friday introduction video located here that has some important information pointing to a few resources that will come in handy when scripting for After Effects.
Episode 13 importAFile:
Legal note: The Adobe ExtendScript code talked about in this article and accompanying embedded video(s), and/or graphic images are not guaranteed to be compatible with every version of After Effects. David Torno, ProVideo Coalition, and Diversified will not be held liable for any misuse or incorrect use of the provided ExtendScript code. Use at your own risk.
All of the code I provide in this series, has been created and tested in After Effects CC 2014. Unless otherwise specified in the episode, the code should be compatible with After Effects CS6 through CC 2015. I’ve done my best to avoid depreciated code (code that Adobe removed at some point), and made these functions as compatible as possible. There will however be the occasional piece of code that is brand new as of a certain version of After Effects and therefore will not be backwards compatible from that version. I will mention these if that is the case.
With that said, all the code I provide in this series is open source and free to use in your scripts. I highly encourage you to expand and improve upon the code I provide and start making your own custom functions as well, but please do not repost the code I show in this series as is and claim it as your own. If you use any of the code provided in this series please give credit where credit is due. This series is meant to provide, what I feel is useful code, as well as to hopefully further explain ExtendScript and it’s quirks. While the functions we build throughout this series can perform a task all on their own, they are not meant to be a solo script. How you combine them together and expand upon them is when you will gain the most from these functions.