Naming PDF at export using a portion of IDCS4 File name(JS)

I have a script that will use a PDF Export Preset to export each page of a document individually. The script uses the ID document's name and adds an "_Final".
For example:
ID docs name:
138-140 TEST 10_WORKER.indd
Final PDF's name:
138-139 TEST 10_WORKER_Final_1.pdf
138-140 TEST 10_WORKER_Final_2.pdf
138-140 TEST 10_WORKER_Final_3.pdf
The first three numbers represent the first page number in the document. I would like it to use these numbers and progressively add one to the following PDF page numbers. I am looking for it to do this while using our standard naming convention which looks like this. . .
MYTEST_138.pdf
MYTEST_139.pdf
MYTEST_140.pdf
Any guidance would be greatly appreciated. Thanks!

The substr(start,length) stuff is in the OMV (under Javascript's Core Classes, class String -- and if you are interested in further developing your JS skills you might want to check my version of this clumsy system!).
Shonky cuts off the first three characters and instructs Javascript to forcibly convert them to a number -- the parseInt command (and that's in the OMV Core Classes under "Global"). parseInt returns the numerical value of the string if it contains digits, or the special value NaN ("Not-a-Number") if it's not. Hence the 'typeof' check -- which, incidentally, I didn't know, but I can guess at what it does. I bet it returns 'true' if the variable contains a number, 'false' if not; and NaN is per definition not a number. (That's computer logic, that is!)
The check is necessary because you want to add something to it as a number; and JS also allows 'adding to a string'. Suppose the first three characters are "hey", adding 1 to it would return the syntactically correct result "hey+1", but it's not what you want here (more computer logic!).
The GREP you point to is quite a bit smarter than assuming the first three, and only three, characters are in fact digits. Some testing shows that this
n = decodeURI(app.activeDocument.name).replace(/^(\d+).*/, '$1');
alert (n);
returns one single string consisting of all digits at the front of your file name. I had to try this out one character at a time ... but, eventually, it boiled down to this:
^(\d+).*
^  start of text
(..) group number 1
\d any digit
+ one or more of the preceding code
. any character
* zero or more of the preceding code
$1 recall found group number one
.. thus (you'll have to take my word for it) it puts all digits at the start of the file name into group one, gathers the rest, and replaces all of it with the contents of group #1 (which still contains the first digits, remember?). So the entire file name is replaced with just the digits in front.
If you are thinking "Hey, I can use this", you are not done here. This GREP operation returns a string type, and to convert it to a number you have to tell JS to do so:
n = Number(n);
.. and now you can add 1 to it the usual way. It's also possible your file accidentally does not start with one or more digits, and in that case the variable 'n' will be empty, so you have to test for n = '' before converting to a number.
The GREP is smarter, because it can find any number of digits, which would be a much more difficult task with plain string manipulations, and it automatically rejects (i.e., stops at) the first non-digit.

Similar Messages

  • File Export use last usage settings of File Export Wizard

    how convert a color photo to grayscale? cs6 fireworks / adobe cloud,...    File > Export use last usage settings of File > Export Wizard???

    There are a lot of different ways to create greyscale images. Here are three methods:
    Select the bitmap and choose Commands > Creative > Convert to Grayscale.
    This is a quick but destructive method, meaning that it modifies your original image. To preserve your original image, you could first make a copy using the Edit > Clone command.
    Select the bitmap and apply a Hue/Saturation effect.
    This effect can be found in the Properties panel within the Filters menu, under Adjust Color. Set Saturation to -100.
    Select the bitmap and apply the Convert to Alpha effect.
    This effect can be found in the Properties panel within the Filters menu, under Other. Set the document canvas to White.
    At least one of these should work for you.
    Unfortunately, I can't quite understand the portion of your question regarding File > Export and the Export Wizard. If English is not your native language, you might try using Google Translate to compose your question.

  • When bates numbering a .pdf in XI, how can I change the file name to include the bates number AND its name?  I know under file output, there is an option for either/or.  I want both.  Thank you.

    when bates numbering a .pdf in XI, how can I change the file name to include the bates number and the file name?  I know under "file output: it's either/or.  I need both.  Thanks!

    Long ago I wrote a little demo using the touch command. Check out the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=25128#M25128
    LabVIEW Champion . Do more with less code and in less time .

  • How to use javascript to "save as" using form data in the file name

    I want to be able to use a button to "save as" and have it automatically pick up and use certain data from the fields in the file name. without having to manually type in the file name.
    Name: john doe
    Date: 1-25-13
    file name would be  (john doe 1-25-13)

    You will need two parts for this. A folder level script (which you place in a .js file under the JavaScripts folder of Acrobat), and a script embedded in the file itself (probably attached to a button).
    The folder-level script will look like this:
    var mySaveAs = app.trustedFunction( function(oDoc,cPath) {
        app.beginPriv();
        try {
            oDoc.saveAs(cPath);
        } catch(e){
            app.alert("Error During Save");
        app.endPriv();
    The doc-level script can look something like this (of course, you might need to adjust the names of the fields used):
    var filePath = this.path.replace(this.documentFileName, "");
    var newFileName = this.getField("name").valueAsString + " " + this.getField("date").valueAsString + ".pdf";
    mySaveAs(this, filePath+newFileName);
    You should be aware that several characters are not allowed in the file name, including comma's, forward- and back-slashes, line-breaks and excalmation marks, so if you try to use them the script would fail. It is possible to create a more advanced version of this script that will automatically remove such characters from the file-name, or alert the user if they used them.

  • Problem using af:inputfile when only file name is given without path.URGENT

    Hai Friends,
    I am using input file type and <h:commandLink to upload a file. But when I type only the file name without the path like(hello.jpg) and try to submit then a javascript error occured "Access is denied". But my requirement is when i type without the path, that is only the file name i need to do some validations, like appending a global path with this file name and upload the file... the following is the code am having...
    <af:form id="address" usesUpload="true" >
    <af:inputFile id="id" value="#{BKb.batchFile}"/>
    <h:commandLink action="#{.uploadFile}">
    <h:outputText value="Upload" styleClass="buttonNoDecoration"/>
    </h:commandLink>
    <h:commandLink action="#{BKb.clearFile}">
    </h:commandLink>
    </af:form>
    can u help me in this issue...
    Thanks in advance,
    Ciya

    I figured out the problem, and it was caused by JHeadstart. I placed a default display value in JHeadstart for the download link. This caused a default values bean to be created by jheadstart and that bean was what was causing my problem. The download link had a display value, but not a valid path. I removed the default value, re-generated the screen and it is totally fixed. I have pretty much decided that it is never a good idea to use a default value in Jheadstart.
    Thanks for your help,
    Michelle

  • Export to excel in WD ALV - file name change

    Hello All,
    As of now in standard WD ALV we have export to excel option which will pop a window to save the file with the default file name as excel.xls but we want to change the file name from Excel.xls to Download_username_date.xls at run time.
    can you please help me for this requirement.
    Thanks,
    RaJ.

    CL_SALV_WD_CONFIG_TABLE provides quite a few methods for the alteration of WD-ALV-Grid, maybe you can find something helpful here.
    regards, Lukas

  • Is there a way to relink to folder and only use a selected part of file name

    I would like to be able to choose to use just the first 3 places of the file name to relink my graghics files. ie:  001, 002, 003 and have it ignore the rest of the file name, we can now change the extender, could this feature be expanded to enclude more options.  Or is there a plugin that will aready do this?

    Did you transfer the telephone number from the old phone to the new phone?  If you did, I don't see how you could still have cellular service, even if you turned it off in settings.

  • I just downloaded iOS 8 on my iPad air. This has caused the file names of all of my PDFs in iBooks to revert to their original file name when I downloaded the file, not the custom file names I gave them after downloading the files. In the list of fil

    PDF file names changed with iOS 8

    Further to above
    Progress Notable!
    But before I outline the details, I wish to apologise to APPLE for laying the blame at their doorstep for loosing or misplacing those PDFs I have on the iPad 1, when I set up my iPad Air , by restoring from the backup of iPad 1, thus copying all data from the old to the new.
    NOT REALLY THEIR FAULT AT ALL
    Because a lot of the many PDFs had the same name, ie PDF.pdf, probably my fault more than anybody else's, so I can't blame APPLE for that. Just goes to show one should be a little more precise in creating these portable documents.
    No wonder the poor program " lost its' marbles" when doing the updating and conversion/transfer.
    However, I was able to recover most of them by personal email, and extracting and RENAMING the PDFs as I located them in their new home.
    Those PDFs that we're locked an thus not email-able , I will deal with by
    Viewing
    Photoeing (if that's how you spell it).
    And re-building the PDF from the photos, in unlocked format, after transferring these files either by Bluetooth or Wi-Fi, from the old to the new iPad.
    So all is not lost, and I am thankful that my cautious approach to this matter in the first place, gave me the ability for this successful recovery.
    That's my story and I'm sticking to it.
    I hope this little story of my saga/experience may prove helpful to others yet to cross the chasm of updating.
    Regards to all, including APPLE.
    NICE STUFF YOU MAKE.

  • Use job parameter as output file name "alias" ?

    I have a Hyperion 9.3 job with a # of cycles. Is there a way to tell Hyperion to use the job parameter/filter as part of the file name? For example, if there is a filter called "division" and for one of the cycles that is set to "sales", is there a syntax like "{division}" I can use in the output file name so that it picks up the filter?

    Unfortunately, I have never seen any kind of syntax that would allow this in Hyperion. The only way I know to do it would be using the java sdk, but that is not something that can be done on the fly...

  • Why can I no longer use a period in a file name for Adobe Reader?

    I was using Google Chrome to view pdf's but Chrome wasn't following the field tabbing order of the pdf.  To resolve this issue, I decided to try disabling Chrome's pdf viewer so that pdf's would open in Adobe Reader.  It didn't go as planned and decided to go back to using Chrome's pdf viewer.  I can no longer rename a pdf with a period.  Is there a setting may have changed?  I don't know if this is an Adobe or a Chrome issue but I thought I would start with Adobe.  Thank you!

    Naming a file with a dot is a dangerous and unpredictable thing to do. Whether it works CAN depend on what comes after the dot.

  • Why is it that, in HTML documents, other browsers treat both forward and backward slashes the same whether used in local or Internet file names, whereas Firefox only treats them the same in local (PC) names but differently in Internet file names?

    I've tested this using several versions of Firefox (from 3.6 to 10.?) under both Windows XP and Windows 7.
    Using either a backward slash (\) or a forward slash (/) in an <A HREF="..\home.htm"> link works fine when testing the document locally; but after installing it online the backward slash is no longer recognized as a file separator.
    While the mistake was mine, the inconsistent treatment of the two slashes made it impossible to catch the problem until it was installed, resulting in a badly mangled website. Competing browsers (such as Internet Explorer and Google Chrome) don't have this problem.

    see http://bbs.archlinux.org/viewtopic.php?id=9107 to use a different cipher and improve speed. might help.
    btw are you sure the stuttering is due to pure CPU and not (disk) IO, or a combination of both? look at wait times in top. maybe tweaking your schedulers might help.
    also you can take a look at AFP (netatalk package) as an alternative. who knows, might help you.
    by the way, did you try webdav?

  • Using Finder search not displaying file names

    I'm running 10.6.4 and searching from the finder on an Xserve for a file name 00035.png but it's not showing in the results.
    Any ideas?

    To clarify your question, when you perform the file search through finder, at the bottom of the window is there a place where it says "x items" and is the number shown there greater than zero?
    I am having trouble understanding if your search is returning results but they aren't being displayed, or if you're searching for a file you know is on your drive, but it's not being identified.
    Regards,
    -Ryan

  • Is there a way to automatically set the file name in Acrobat Properties when exporting a PDF from Indesign?

    When I used Quark to make a PDF, the title area in the PDF was automatically populated with the file name, there in the properties tab. We like use this area to confirm file names of original files, so we can keep track of drafts, (in case the file name of the PDF is changed, which our boss often does). Is there any way to set up InDesign to do the same?

    @stadlock – I think I know what you mean…
    You exported to PDF and changed the file name in the export dialog to a different one from the document name presented there the first time you exported that document. And in exports after that the new name will be presented in the dialog instead of the name of the document.
    What you can do against that?
    1. First time you want to export: Save before the document is exported. And do not save after it's exported with a new file name.
    2. After the new file name is already there in the export dialog:
    Type in the document name in the dialog. Export. Or abort after chosing a export preference. Save. Check again, if the document's file name is in the export dialog. If yes, procede like in suggestion #1. If not do a full export with the document's file name, save and then procede with suggestion #1.
    Uwe

  • Script to export IDCS3 to PDF utilizing text from document as file name

    I have written a few very very basic scripts so I really only know enough to be dangerous. I tried searching the forums first but couldn't find a situation quite like this one.
    I have an IDCS3 file that is using data merge to create multiple files. After the merged document is created I want to export the pages individually with a file name that is derived solely from information in one of the text frames on each page.
    Example: page 1 has text frame with the text, Style 1002. I want the file name to be 1002, or it could be Style 1002 if need be.
    Page 2's text frame says, Style KL303. Same here, I want the file name to be KL303, or Style KL303.
    Is this possible? Any help or suggestions is greatly appreciated. I have about 400 of these to create and exporting each of them individually, manually, would be a chore.
    Thanks!!

    Ask in the ID forum. Sounds like you need to check your master pages and assign a new template to your pages.
    Mylenium

  • Extracting text from a file name on export / import (Regular Expressions??)

    I’m not even sure if the publishing service, File Naming, in Lightroom supports Regular Expressions or not?? Basically I’m trying to extract the left portion of the file name ie: everything before the underscore “_”. When I import a file I rename the file to reflect the current Image sequence number and then append the date the photo was taken; a typical file is as follows “05625_2008-01-05.dng” on export I would like the new name to be only the sequence number in this case “05625.jpg”. Ideally I would then like to append the folder name that contains the file… “05625 - FolderName.jpg.
    I don’t want to go down the road of figuring out the correct syntax if regular expressions aren’t supported. Thanks in advance - CES

    Is the imported sequence number captured in meta data somewhere or is their somewhere that all of the available fields and there reference names can be found???
    Unfortunately not anywhere available to the user (but it's still stored in at least some filed I know off).
    By the way, why did you choose to put the suffix at the beginning of the name (1234_2010-08-13.jpg)? The common practice is to leave the suffix at the end. That will ensure the filenames will sort in chronological order by filename and you could have easily used the suffix when exporting files. You wouldn't have this problem now.

Maybe you are looking for