-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrganizeFoldersRename.jsx
55 lines (47 loc) · 1.4 KB
/
OrganizeFoldersRename.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<javascriptresource>
<name>Organize Folders and Rename</name>
<about>
This will color code nested folders to help readiblity.
It will also rename layers.
- Evan Viera
</about>
<menu>filter</menu>
<category>Viera</category>
<type>automate</type>
<enableinfo>true</enableinfo>
</javascriptresource>
#include "vieraLibrary.jsx"
var doc = activeDocument;
var idColors = [ "Rd ", "Orng", "Ylw ", "Grn ", "Bl ", "Vlt ", "Gry " ];
var lastColor = 0;
var groupNum = 0;
colorGroupTags( doc );
// ****************************************
// Collects all layers underneat into array
// ****************************************
function colorGroupTags( __parent )
{
var refLayer = new RegExp( /_REF_/gim );
for ( var i = 0; i < __parent.layers.length; i++ )
{
var currentLayer = __parent.layers[ i ];
var visible = currentLayer.visible;
if ( !currentLayer.name.match( refLayer ) )
{
if ( currentLayer.typename == "ArtLayer" )
{
currentLayer.name = "LYR_" + i; // + "_" + currentLayer.blendMode;
}
else
{
doc.activeLayer = currentLayer;
setLabelColor( idColors[ lastColor ] );
lastColor = (lastColor + 1) % idColors.length;
currentLayer.name = "GRP_" + groupNum;
groupNum++;
colorGroupTags( currentLayer );
}
}
currentLayer.visible = visible;
}
}