Adobe 12040118 Using Help - Page 183
Save and increment, Now we set the currFileName variable to the current name, before the dot.
UPC - 718659361808
View all Adobe 12040118 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 183 highlights
Help Using Help Examples Back 183 Save and increment Although much of the functionality of this script has been superseded by the incremental save feature that is new to After Effects 6.5, it is still included here because it makes effective use of conditionals, functions, and the File and FileSystem objects. This script automatically saves a new copy of the open After Effects project and increments a three-digit number in its name to distinguish it from preceding versions of the project. This script is saved as save_and_increment.jsx on your install CD. The first step is to determine whether the currently open project has ever been saved. This is accomplished with an opening if/else statement. The first condition, "!app.project.file" is saying that if the project has not been saved, an alert telling the user to save the project is popped up, and the script ends. if (!app.project.file) { alert ("This project must be saved before running this script."); Next, if the project has been saved at least once before, we set some variables to point to the name of the file and to the numbering and file extension that we plan to add to it. The lastIndexOf() JavaScript searches a string backwards (from end to start) and in this case looks for the dot that separates the name from the extension. } else { var currFile = app.project.file; var currFileName = currFile.name; var extPos = currFileName.lastIndexOf("."); var ext = ""; Now we set the currFileName variable to the current name, before the dot. if (extPos != -1) { ext = currFileName.substring(extPos, currFileName.length); currFileName = currFileName.substring(0, extPos); } Next we set a variable that will increment versions starting with 0, and we check to see if there is an underscore character four characters from the end of currFileName. If there is, we assume that the incrementer has run before, as its job is to assign a 3-digit suffix after an underscore incremented one higher than the last suffix. In that case we set incrementer to the current numerical string and extract the name without this numerical extension. var incrementer = 0; if (currFileName.charAt(currFileName.length -4) == "_") { incrementer = currFileName.substring(currFileName.length - 3, currFileName.length); currFileName = currFileName.substring(0, currFileName.length -4); } Now we add an incrementer loop and test for whether numbering has extended to two or three digits (e.g., if the numbering has reached "_010" or above, or "_100" or above), assigning a zero for each if not. incrementer++; var istring = incrementer + ""; if (incrementer < 10) { istring = "0" + istring; } Using Help Back 183