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;
}
...
Export a file without the unique ID file name
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Re: Export a file without the unique ID file name
Code: Select all
var name = $filename.right($filename.length-7);
Re: Export a file without the unique ID file name
thanks dkelly, but JavaScript does not offer Left and Right functions.
Works with
var name = $filename.substring(7, $filename.length);
Works with
var name = $filename.substring(7, $filename.length);
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
Re: Export a file without the unique ID file name
Switch does
and for Adobe apps you can define asleft( 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.
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);
}
}
Last edited by dkelly on Tue May 26, 2015 6:21 pm, edited 1 time in total.
Re: Export a file without the unique ID file name
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.pcarvalho wrote:JavaScript does not offer Left and Right functions.
FWIW,
Loic