Skip to content

Instantly share code, notes, and snippets.

@kostimarko
Created August 17, 2019 21:02
Show Gist options
  • Save kostimarko/a9a5e034ba363b48611ab9094e48baeb to your computer and use it in GitHub Desktop.
Save kostimarko/a9a5e034ba363b48611ab9094e48baeb to your computer and use it in GitHub Desktop.
function getNewName(layerName){
// Local Variables
var docName;
// Set docName to the source doc name
docName = sourceDoc.name;
// Set newName to empty string
var newName = "";
// Get the last underscore in the document name
var underscore = docName.lastIndexOf('_');
// Set newName to the docName from the first char to the last underscore
newName += docName.substring(0,underscore);
// Set newName to underscore + layerName
newName += '_' + layerName;
// Save in file at destFolder and newName
saveInFile = new File(destFolder + '/' + newName);
// Return saveInFile that creates file at folder path
return saveInFile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment