Sg2.9
Make Layer Name the same as D...
Recent RSS
Make Layer Name the same as Document name.
From:  Justin
Date:  1. October 2013, 01:55

Hi I would like to make the active layer name the same as the document name. I know very little about scripting. I found this script:

var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;
var filename = idoc.name;
ilayer.name = filename;

It does almost what I need it to do. except that it also copies the ".ai" in to the layer name. Is there some way to modify this script to have it exclude or delete the file extension?

Thanks for any help.

Re: Make Layer Name the same as Document name.
From:  pqbd
Date:  1. October 2013, 05:04

This will take the file extension off of a string:

filename = filename.split('.');
filename.pop();
filename = filename.join('.');

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Stroke <-> Fill 09.01.08