Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Files not saved out path

New Here ,
Jul 21, 2013 Jul 21, 2013

Hi Forum,

I am converting IDML to INDD in specific paths of IN and OUT folders, my JS is opening multiple files only, but not saved to out folder

please can one correct my error

my JS:

checkDocLen()

var myDoc;

var mySourceFolder = Folder("/Volumes/User/Desktop/IN");

var myOutFolder = Folder("/Volumes/User/Desktop/OUT");

var Idml_files = get_File(mySourceFolder,[],'.idml');

if(Idml_files.length>0)

{

    for(var w=0;w<Idml_files.length;w++)

    {

        try{

            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

            myDoc = app.open(File(Idml_files));

            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

            var myDocNam = stripExt((Idml_files.name).replace(/%20/g," "))+"indd";

            myDoc.save(File(myOutFolder+"/"+myDocNam));

            app.activeDocument.close();

        }catch(E){}

    }

}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function get_File(dir,myfile_arr,extension)

{

    var f = Folder( dir ).getFiles();

    for( var ifil = 0; ifil < f.length; ifil++ )

    {

        var mystr=f[ifil]+"";

        var aa=mystr.match(/\/[.]AppleDouble/)

        var bb=mystr.match(/[_]VUC69~7/)

        var cc=mystr.match(/DS[_]Store/)

       

        if( f[ifil] instanceof Folder )     //change

        {

            if((aa==null) && (cc==null))

            {

                get_File( f[ifil],myfile_arr,extension)

            }

        }

        else

        {

            if(extension!=".*")

            {

                if( f[ifil].name.substr( -extension.length ) == extension )

                {

                    myfile_arr.push(f[ifil])

                }

            }

            else

            {

                if((bb==null) && (cc==null) && (f[ifil] instanceof Folder == false))

                {

                    myfile_arr.push(f[ifil]);

                }

            }

        }  

    }//for

    return myfile_arr;

}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function stripExt (f)

{  

        return f.substring(0,f.length-4);  

}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function checkDocLen()

{

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

    while(app.documents.length!=0)

    {

        try{

            app.activeDocument.close();

        }catch(e){}

    }

}

Thanks in advance

Simon

TOPICS
Scripting
775
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jul 22, 2013 Jul 22, 2013

change

var mySourceFolder = Folder("/Volumes/User/Desktop/IN");

var myOutFolder = Folder("/Volumes/User/Desktop/OUT");

to

var mySourceFolder = Folder("~/Desktop/IN");

var myOutFolder = Folder("~/Desktop/OUT");

Translate
Explorer ,
Jul 22, 2013 Jul 22, 2013

change

var mySourceFolder = Folder("/Volumes/User/Desktop/IN");

var myOutFolder = Folder("/Volumes/User/Desktop/OUT");

to

var mySourceFolder = Folder("~/Desktop/IN");

var myOutFolder = Folder("~/Desktop/OUT");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 22, 2013 Jul 22, 2013

Hi Mac_rk,

It works in Desktop only, but not working in server, I found it, as your way. Maybe my fault I asked only for Desktop.

the code is:

Folder("/SERVER/LiveJobs/IDML/IN")

Mac_rk wrote:

change

var mySourceFolder = Folder("/Volumes/User/Desktop/IN");

var myOutFolder = Folder("/Volumes/User/Desktop/OUT");

to

var mySourceFolder = Folder("~/Desktop/IN");

var myOutFolder = Folder("~/Desktop/OUT");

Great! Mac_rk

Many Thanks

Simon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 22, 2013 Jul 22, 2013
LATEST

Oops... the question was already answered. Sorry. Some other things got in between before I sent my answer.

// Andreas

Hi,

I changed the paths to desktop to a generic format (since I use windows):

var mySourceFolder = Folder.desktop + '/IN';

var myOutFolder = Folder.desktop + '/OUT';

Then I created an IN-folder on my desktop, put three idml files in it and ran the script. The three files were opened and saved as indd files in the OUT folder. No errors.

I suggest that you add an alert to the error handler, showing any errors.

Or simply step through the script in the ExtendScript Toolkit, and when you are on the line with the save call, just write out the contents of

File(myOutFolder+"/"+myDocNam).fsName

in the javascript console window of the Extendscript Toolkit.

There is probably some error.

Also, there is no need to set app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract more than once.

It may very well be this that hides something for you, you could try running the script with userInteraction set to its default, just to make sure.

Best regards,

Andreas

Message was edited by: Andreas Jansson

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines