Page 1 of 1
Export a file without the unique ID file name
Posted: Mon Apr 27, 2015 5:49 pm
by pcarvalho
I have a script that export a indd file to rtf, xml and PDF.
The resulted files have the unique ID file name (_001OL_Teste_DOC1.rtf).
How can i generate a file without that unique ID?
Heres a portion of the script:
var name = $filename;
//========== Export to RTF ===========
myRTFFile = new File($arg3 + "/" +name+".rtf" );
try{
var myStory = $doc.textFrames.itemByName("a_textframe").parentStory;
myStory.exportFile (ExportFormat.rtf, myRTFFile);
}
catch(theError) {
$doc.close(SaveOptions.DONOTSAVECHANGES);
$error = theError.description;
}
...
Re: Export a file without the unique ID file name
Posted: Mon Apr 27, 2015 10:32 pm
by dkelly
Code: Select all
var name = $filename.right($filename.length-7);
Re: Export a file without the unique ID file name
Posted: Sat May 23, 2015 1:13 pm
by pcarvalho
thanks dkelly, but JavaScript does not offer Left and Right functions.
Works with
var name = $filename.substring(7, $filename.length);
Re: Export a file without the unique ID file name
Posted: Tue May 26, 2015 3:30 pm
by dkelly
Switch does
left( length : Number ) : String
Returns a substring containing the length leftmost characters of this string.
right( length : Number ) : String
Returns a substring containing the length rightmost characters of this string.
and for Adobe apps you can define as
Code: Select all
function left(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
function right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
Re: Export a file without the unique ID file name
Posted: Tue May 26, 2015 5:42 pm
by loicaigon
pcarvalho wrote:JavaScript does not offer Left and Right functions.
You have to distinguish the core language know as Javascript and its different implementations with different object models and extended functions. Also even a basic object like a RegExp object has different methods from where you use it. You won't find Right() in other implementation such as ExtendScript. Most of all, you have to keep aware that inspite a very minimalistic set of primitive objects and function, Javascript can differ widely from one context to another.
FWIW,
Loic