Startup script that make layer visible depending on docs filename
Learn / Forums / General InDesign Topics / Startup script that make layer visible depending on docs filename
Tagged: startup script
- This topic has 1 reply, 1 voice, and was last updated 9 years, 10 months ago by Jonas Ericsson.
-
AuthorPosts
-
-
June 11, 2014 at 5:25 am #68922Jonas EricssonParticipant
Hi,
First: I’m a newbie when it comes to scripting.
The Guru himself, Peter Kahrel helped me to write another script that has the name.search in it and I reused some of it here.I have started to wrote a startup script that set “visible = true” on a specific layer if the document starts with a specific filename. If the first layer doesn’t exist, try “xxx” in the first name.search.
And if the first “name.search” does’nt match I want the script to test the next “name.search”, and the next…The problem I have is that only the first name.search “kicks” in.
How to make the script check the other name.search-lines?
#targetengine “session”
main();
function main(){
var myEventListener = app.eventListeners.add(“afterOpen”, excuteScript);
}function excuteScript(){
var myD = app.documents[0];// if filename starts with ABA (and perhaps 1 more letter) and contains 8 numbers, 3 letters, 2 (or 3) numbers plus.indd
if (myD.name.search(/^\ABA\w?-\d{8}(-\w\w\w)?-\d{2}\d?\.indd/i) == -1) return
try{
var mittLager = myD.layers.item(“AB_serier”);
mittLager.visible = true;
}
catch (myError){
var mittLager = myD.layers.item(“AB_kryss”);
mittLager.visible = true;
}// if filename starts with OOA (and perhaps 1 more letter) and contains 8 numbers, 3 letters, 2 (or 3) numbers plus.indd
if (myD.name.search(/^\OOA\w?-\d{8}(-\w\w\w)?-\d{2}\d?\.indd/i) == -1) return
try{
var mittLager = myD.layers.item(“AM_OA_serier”);
mittLager.visible = true;
}
catch (myError){
var mittLager = myD.layers.item(“AM_OA_kryss”);
mittLager.visible = true;
}// if filename starts with OBA (and perhaps 1 more letter) and contains 8 numbers, 3 letters, 2 (or 3) numbers plus.indd
if (myD.name.search(/^\OBA\w?-\d{8}(-\w\w\w)?-\d{2}\d?\.indd/i) == -1) return
try{
var mittLager = myD.layers.item(“AM_OB_serier”);
mittLager.visible = true;
}
catch (myError){
var mittLager = myD.layers.item(“AM_OB_kryss”);
mittLager.visible = true;
}}
-
June 11, 2014 at 5:47 am #68923Jonas EricssonParticipant
Forgott to change from swedish “mittLager” to “myLayer. Sorry
-
-
AuthorPosts
- You must be logged in to reply to this topic.