Skip to content

Instantly share code, notes, and snippets.

@rewfergu
Created February 25, 2015 23:16
Show Gist options
  • Save rewfergu/fda299eea13628cde6c6 to your computer and use it in GitHub Desktop.
Save rewfergu/fda299eea13628cde6c6 to your computer and use it in GitHub Desktop.
Convert Illustrator files to Symbols
var sourceFolder,
files,
fileType,
sourceDoc,
sourceArtwork,
symbolRef;
//documents.add();
var docRef = documents[0];
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select a folder...', '~' );
// If a valid folder is selected
if ( sourceFolder != null )
{
files = new Array();
fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', ' ' );
// Get all files matching the pattern
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )
{
for ( i = 0; i < files.length; i++ ) {
sourceDoc = new File(files[i]);
sourceArtwork = docRef.groupItems.createFromFile(sourceDoc);
symbolRef = docRef.symbols.add(sourceArtwork);
symbolRef.name = sourceDoc.name;
}
alert( 'symbols converted ');
} else {
alert( 'No matching files found' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment