Adobe 12040118 - After Effects Standard Using Manual page 186

Using help
Hide thumbs Also See for 12040118 - After Effects Standard:
Table of Contents

Advertisement

Help
Using Help
Now we add a function to test whether a given file is part of a sequence. This uses Regular Expressions, which
are a special type of JavaScript designed to reduce the number of steps required to evaluate a string. The first
one tests for the presence of sequential numbers anywhere in the file name, followed by another making
certain that the sequential files aren't of a type that can't be imported as a sequence (moving image files).
We then check adjacent files to see if a sequence exists, stopping after we've evaluated ten files to save
processing time.
functio n testFo rS eq u en ce (fil es){
var searcher = new Re gExp ("[0-9]+");
va r mov ieFil eS ea rch e r = n ew Re gE x p (" (mov |av i |mpg)$" , " i" );
var parseResults = new Ar r ay ;
for (x = 0; (x < files.length) & x < 10; x++) {
//test that we have a sequence, stop parsing after 10 files
var mov ieFileResult = mov ieFileSearch er.exe c(files[x].name);
if (! mov ieFileResult) {
var cur rentResult = searcher.exe c(files[x].name);
If no match is found using the Regular Expression looking for a number string, we get null and assume there
is no image sequence. Otherwise, we want an array consisting of the matched string and its location within
the file name.
if (cur rentResult) {
//we have a match - the st r ing contains numbers
//the match of those numbers is stored in the ar r ay[1]
//take that number and save it into parseResults
parseResults[parseResults.length] = cur rentResult[0];
}
e l s e {
parseResults[parseResults.length] = nu ll;
}
}
e l s e {
parseResults[parseResults.length] = nu ll;
}
}
Now if all of the files just evaluated indicated that they are part of a numbered sequence, we assume that we
have a sequence and return the first file of that sequence. Otherwise, we end this function.
v a r res u l t = nu l l ;
for (i = 0; i < parseResults.length; ++i) {
if (parseResults[i]) {
if (! result) {
result = files[i];
}
} e l s e {
/ / case in wh ich a fi le n a me did n ot con ta i n a nu mb e r
res u l t = nu l l ;
break;
}
Using Help
Examples
Back
186
Back
186

Advertisement

Table of Contents
loading

This manual is also suitable for:

After effects

Table of Contents