Skip to main content
Inspiring
January 15, 2019
Answered

How to define app.activeBook.fullName ?

  • January 15, 2019
  • 2 replies
  • 770 views

Hi experts,

my script like this:

        var myFolder=Folder(app.activeDocument.fullName);

        var myFolder= Folder(app.activeBook.fullName); 

               if(myFolder.parent.fsName.match(/M:\\Announcement/)) {

                    return File(adPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/M:\\Document folder/)) {

                    return File(cirPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/J:\\/)) {

                    return File(arPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/K:\\/)) {

                    return File(irPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/N:\\/)) {

                    return File(ipoPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/Shun Hing folder/)) {

                    return File(shunhingPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/L:\\Other Folder/)) {

                    return File(othersPath + cName);

                    }

how to define:

var myFolder=Folder(app.activeDocument.fullName || app.activeBook.fullName);

??

thanks

regard

John

This topic has been closed for replies.
Correct answer Johnwhite

thank you guys

I change it :

var

  myBooks = app.books.everyItem().getElements();

        if (myBooks.length) {

            myFolder= Folder(app.activeBook.fullName);

            }

        else {

            myFolder= Folder(app.activeDocument.fullName);

            }

               if(myFolder.parent.fsName.match(/M:\\Announcement/)) {

                    return File(adPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/M:\\Document folder/)) {

                    return File(cirPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/J:\\/)) {

                    return File(arPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/K:\\/)) {

                    return File(irPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/N:\\/)) {

                    return File(ipoPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/Shun Hing folder/)) {

                    return File(shunhingPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/L:\\Other Folder/)) {

                    return File(othersPath + cName);

                    }

it works ok,

thanks so much.

John

2 replies

JohnwhiteAuthorCorrect answer
Inspiring
January 15, 2019

thank you guys

I change it :

var

  myBooks = app.books.everyItem().getElements();

        if (myBooks.length) {

            myFolder= Folder(app.activeBook.fullName);

            }

        else {

            myFolder= Folder(app.activeDocument.fullName);

            }

               if(myFolder.parent.fsName.match(/M:\\Announcement/)) {

                    return File(adPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/M:\\Document folder/)) {

                    return File(cirPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/J:\\/)) {

                    return File(arPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/K:\\/)) {

                    return File(irPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/N:\\/)) {

                    return File(ipoPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/Shun Hing folder/)) {

                    return File(shunhingPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/L:\\Other Folder/)) {

                    return File(othersPath + cName);

                    }

it works ok,

thanks so much.

John

Sunil Yadav
Legend
January 15, 2019

Try this code,

var myFolder=Folder(app.activeBook.filePath);

//OR

var myFolder=Folder(app.activeDocument.filePath);

JohnwhiteAuthor
Inspiring
January 15, 2019

thank you yadavs

thanks so much.

but my script like this:

var

        adPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/AD/";

        arPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/AR/";

        cirPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/Cir/";

        ipoPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/IPO/";

        irPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/IR/";

        shunhingPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/Others/Shun Hing/";

        if (!Folder (shunhingPath).exists) { 

            Folder (shunhingPath).create(); 

            } 

        othersPath = "//192.168.0.102/72dpi output/" + "_______to CS PDF" + "/Others/";

  cName = cFile.name.split(".")[0],

  cTime = new Date;

          cName += "-" +

                ("0" + String(cTime.getDate()) ).slice(-2) +

                "-" +

                cTime.monthName() +

                "-" +

                ("0" + String(cTime.getHours()) ).slice(-2) +

                ("0" + String(cTime.getMinutes() ) ).slice(-2) +

                ".pdf";

               

        var myFolder= Folder(app.activeDocument.fullName||app.activeBook.fullName);

               if(myFolder.parent.fsName.match(/M:\\Announcement/)) {

                    return File(adPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/M:\\Document folder/)) {

                    return File(cirPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/J:\\/)) {

                    return File(arPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/K:\\/)) {

                    return File(irPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/N:\\/)) {

                    return File(ipoPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/Shun Hing folder/)) {

                    return File(shunhingPath + cName);

                    }

               else if(myFolder.parent.fsName.match(/L:\\Other Folder/)) {

                    return File(othersPath + cName);

                    }

it error on if there is a book is open but not any doc