Copy link to clipboard
Copied
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
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
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");
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now