Increments with saveAs file name

Hi all

I am trying to create a script that called the current file as w1.pdf and then eventually would name the file w2, etc..

If we are working on w9.pdf and run the script, you guessed it... W10.PDF

Can I use the increment with saveAs operand? All of my efforts just keep adding things on behalf of file, not incrementtally by changing the file name.

Thanks in advance for any help,

Hello Kent, of course it is possible.  But of course must do from a script from folder level, because unable to use the Save function as in a script of a document.

The basic technique is to acquire the name of file, determine if it matches the expected format and to analyze the current number.  Increment the number, and then generate a new file name.

For example, copy the following code uses a regular expression to perform the task:

Corresponds to 'l' followed one or two digits

var rgFlNm = / ^ w (\d {1,2});

If (rgFlNm.test (this.documentFileName))

{

var NouveauNomFichier = 'w' (Number(RegExp.$1) + 1) m:System.NET.SocketAddress.ToString ();

this.saveAs (newFileName);

}

on the other

App.Alert ("file name does not match the expected format");

Here, the code displays an alert if name of file format does not match 'w', followed by one or two digits.  But you could have the default filename or ask the user what they want to do.

Thom Parker
The source for PDF Scripting Info
pdfscripting.com

The Acrobat JavaScript Reference, use it early and often
http://www.Adobe.com/devnet/Acrobat/JavaScript.html

Then more important JavaScript development tool in Acrobat
The Console window (video tutorial)
The Console Window (article)

Tags: Acrobat

Similar Questions

  • Need help with script java folder level for silent registration with unique file name

    That's what I'm trying to do

    1. when a person completes the request on one of our computers in the office, there will be a button send at the bottom of the application.

    2 submit the application on is automatically stored on the local server with the file name determined by the fields name and surname on the application.

    example - John Doe Application.pdf

    Saved in the folder C:\Users\Station1\Desktop\FinishedApplication.jpgApplications

    3. This is the example of code I found, but I don't know how to enter which fields determine save name and where to save it to.

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html

    http://thelivecycle.blogspot.de/2015/06/save-with-new-name-in-specified.html http://thelivecycle.blogspot.com/2009/11/save-form-to-specific-directories-and.html

    Thank you!

    Lol this is the part that you need as a script to the folder level:

    var lcbSaveAs = app.trustedFunction (function (vDoc, vPath) {}

    app.beginPriv ();

    vDoc.saveAs ({cPath: vPath});

    app.endPriv ();

    });

    This is the code you use in your file:

    lcbSaveAs (, "/ C/users/specialisee1/Desktop/result /" + this.getField("FirstName").valueAsString + "" + this.getField("LastName").valueAsString + "Application.pdf");

    lcbSaveAs is the name of the function of trust.

    vDoc.saveAs is the Document object, call the saveAs method.

    I don't know what oDoc.SaveAs is, or where you got it.

  • "Cannot save (file name) because the file is already in use or left open."

    Hello
    When I tried to save as a file, I get an error msg:
    "Cannot save (file name) because the file is already in use or left open."

    The file is unwilling to accept any Photoshop.

    Mac Pro, OSX 10.5.6
    Photoshop CS4.

    I searched the Forum but did not find anything even though I'm sure someone has already asked it.

    would love to get a solution for this.
    Thank you
    Shlomit

    If Photoshop says that the file is opened - then some external process left the file open. It has nothing to do with it being open in Photoshop, or even in the bridge. This sometimes happens when Spotlight had bugs (who came more than once and been corrected in versions of dot operating system).

    The external process could be another application or service to OS like Spotlight.

  • Rename presets with the file name

    Hi guys,.

    I currently using presets to change my image but the name is so angry, he does not follow any order naming, just a total mess. I am using a batch program rename to rename this (filename), then import it to lightroom and realize that the name has not changed.

    "I Googled it and look like I need to change the ' title = ' with the text editor to change the name in lightroom. But I will have hundreds of presets and cannot change each of them manually more (past 4 hours to change the name of the file).

    Are these anyway that I can change the name of the fastest presets? Any program that correspond to the "title =" with the file name?

    Thank you

    User presets, click with the right button on the preset in the develop module, and then choose Rename.

    Batch renaming presets of in Lightroom is not possible.

  • XFA form with button to save the file with unique file name

    Is it possible to save a file with a unique file name by using the data that a user has entered (name, e.g.) that fires when the user clicks a button print? Attached is a file reference.

    Hello

    Yes it works here using your latest form and the modified .js:

    You have created the folder 'HSSSave '?

    Also, make sure the .js file is in the correct application folder and restart Acrobat:

    Hope get you it working (and when you do you can include a timestamp or timestamp in the name of file; as the script automatically replaces an existing file with the name of TEA).

    N.

  • How to increment a PDM file name

    Hello

    I have a vi that register data in a PDM file. So I'm using tdms open file and write to the file of PDM. In addition, I want to increment the file name. The user must write the name of the file, for example if the file is named test I want to the next file is called test1, test2, etc.. Now, if I forgot to change the file, simply replace automatically and I lose all my saved data.

    Can you help me to get an easy method to save the data in the file with the incremented automatically name please.

    Thank you

    Hi Nico_AT

    Maybe what your are looking for? The just VI tries to start the file. Is there no mistake it will be close and start the following and so on.

    Concerning

    Tobias

  • Submit a form with specific file name

    Greetings!

    I'm not really any script, so I could really use some help.

    First of all – and especially:

    I have an Acrobat X Pro PDF form with a submit form button that is routed to a specific e-mail address.

    The native of Sharepoint and generates a file name long pdf filled with characters '% '.

    Is there a way to specify the name generated for the PDF file?

    I would be very happy if I can get the above scenario work...

    But I know that the question will be...

    Is to join a field of shape to this PDF file name anyway?

    As follows:

    SpecificFileName_EmployeenameField.PDF

    Still - I'm not a javascript person, otherwise I'd know if it was possible.

    And Yes, I'd like some recommendations on books / resources for scripts with Javascript.

    Thanks to anyone who can help to shed light on this.

    -You cannot specify the name of the file which is presented.

    -You can save the file by using the value of a field, but that requires a level of the file script installed on each user's computer using this file.

  • Error: Could not save 'file name' because the file name was invalid. (PS CS6 + WIN 7)

    I recently bought a new desktop in WIN 7, but also Adobe Creative Suite CS6.

    My first internal hard drive 2 TB is the second installed is from my old PC, 250 GB.

    I get this error when you try to save a file to a file using the Save"" command.

    The message is false, because the file name IS valid.

    This error is persistent.

    This error will not occur when you perform the same operation on my second internal hard drive.

    This error occurs on the files above about 1 MB in weight.

    What is happening is that the original file which I try to do the "Save" command gets corrupted and lost.

    If I do not use the command "Save as" to save my work under a different name, my work is lost.

    The same problem occurs with the CS6 PS 64-bit and 32-bit versions.

    I am very disappointed and annoyed with what is happening.

    Any idea what's going on here?

    Then Yes, sugarsync may have much to do with the error.

  • Cannot delete files with long file names in Windows 7

    Unnecessary Windows 7 will not erase a file whose name is too long. I have no name, it is in a temporary folder of IE. I can't get rid of it as options to rename will not be visible.

    Thanks, but I have solved the problem. The error message was about 'file path or destination file name is too long. It is the backup to the temporary internet file that was causing a problem: he made the PATH too long as she added additional elements on the path. That was simply solved by the path to 2 bits, (path upper and lower file path) to cut and remove separately.

    When I tried to delete the .jpg image with the extremely long filename at the end of the long path he says as the destination folder (ie the TRASH) could not hold the file due to excessive length. It's confusing to say the least.

    Anyway that little trash has bit the dust.

  • Find photos with different file names?

    Somehow, I have photos with different names. Example: 2015-04-08 13.28.25.jpg and IMG_1668.JPG.

    Trying to get all the photos into the Lightroom Catalog, I am unable to find any pictures unless I know the two names - which I did not.

    And my DuplicateFinder are not nameless a base file name.

    Any ideas?

    Sheila

    Lightroom doesn't have a function automated for something like that, but there are third-party plug-ins. See, for example, here: Finding of pictures duplicate in Lightroom

  • Open a RAW file with the file name right but wrong picture / no image I chose!

    Suddenly new bug in my Photoshop CC 2015. It is a few days, he has begun to allow me to choose "open file", select a RAW file in my picture folder, click Open and then he shows me a different photo in RAW, but with the correct file name. That's happened? I changed nothing in the month and work on Nikon or Canon RAW files almost daily. Help!

    You open the images of the bridge?  If so, try to purge the image cache

    What operating system do you use?

    You have everything installed miniature viewers?

    Problems with Canon and Nikon RAW files?  If just of Nikon, have already opened images with the Nikon RAW files Viewer?

  • Why Photoshop CC2015 open a RAW file with the file name right but wrong picture / not the picture that I chose?!!?!

    Suddenly new bug in my Photoshop CC 2015. It is a few days, he has begun to allow me to choose "open file", select a RAW file in my picture folder, click Open and then he shows me a different photo in RAW, but with the correct file name. That's happened? I changed nothing in the month and work on files Nikon or Canon RAW almost every day... that is something new that I need to find a patch or something that I am on... Help!

    Hi Modernmatt,

    I suggest you contact adobe support chat

    Please click on the link below-

    Contact the customer service

    Concerning

    Rohit

  • How watermark with the file name?

    I've searched and searched and I can't find an easy way to do this... but it MUST be possible!

    Some (really clumsy) Solutions, I found:

    1. I can create a .csv with two columns, each list of filename for each image in a folder.  Then, using variables in PS, I use the first column as a variable image replacement and the 2nd column as a text replacement variable to export the files.  This solution is both your time and creates images that are all the same size.
    2. LR/Mogrify plugin 2 - what might do the trick, but it doesn't seem to work with the latest version of LR
      • (I get this error: an internal error occurred: LRCatalog; withCatalogDo has been marked obsolete in Lightroom 2.0 and is not supported from Lightroom 3.0) This call is necessary.)
    3. Somehow use a droplet, pulling on the name of the metadata file to generate a watermark text... which I can't figure out how to do.

    How can this be complicated?  There must be a clear Super button, Miss me him somewhere in LR, because I can't imagine NOT having need of this feature.

    Help, please!

    You can do it in the slideshow module. By clicking on the ABC button on the toolbar and choosing the file name in the menu dropdown. You can drag the text box anywhere to anchor it in the Center, downstairs, etc. top of page. You can print a whole batch to PDF. See image:

  • Bringing data from Excel, same content with different file name

    Hello world

    I was download data from Excel files with success so far.

    The files that I used to download, have had the same 'FileName.xls '. Now, what I have is a workbook with a different name, so I guess as it was not created on the ODB like that he will not be transferred, in the name of the file is the same. Let me explain better.

    MYBEAUTIFULXLS.xls - before
    MYBEAUTIFULXLS_MORETEXT.xls - now

    Can I use something like MYBEAUTIFULXLS % somewhere on the ODI, for him to download data from the files that begin with the characters?

    I really appreciate your ideas!

    Best regards.

    J_ORCL

    Option 1 seems to be preferable, because there is risk associated with the 2nd.
    And debugging will also be little difficult.

    This is my personal opinion only... you can choose the desired option.

    Thank you
    Fati

  • Export pages to jpg with custom file names

    Hello world

    I found - and slightly modified - this script that exports each InDesign page in jpg format, naming it with the relative page number.

    I need to assign the value of a text that I have placed on each page, which is decorated with a paragraph called "filename" style file name

    It would also be good to have user-friendly web file names, replacing spaces with dashes and turn them into tiny.

    Thanks in advance for your help.

    if (app.documents.length != 0) {
         var myDoc = app.activeDocument;
        MakeJPEGfile();
    }
    else{  
         alert("Please open a document and try again.");  
    } 
    
    function MakeJPEGfile() { 
         for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
             
              if (myDoc.pages.item(myCounter).appliedSection.name != "") {
                   myDoc.pages.item(myCounter).appliedSection.name = "";
              }
              var myPageName = myDoc.pages.item(myCounter).name;
              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
              app.jpegExportPreferences.exportResolution = 72;
              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
              app.jpegExportPreferences.pageString = myPageName;
    
              var myFilePath = "~/Desktop/" + myPageName + ".jpg";
              var myFile = new File(myFilePath);
              myDoc.exportFile(ExportFormat.jpg, myFile, false);
         }
    }
    

    This code is the same as above, but with a few modifications and a new fuction

    if (app.documents.length != 0) {
         var myDoc = app.activeDocument;
        MakeJPEGfile();
    }
    else{
         alert("Please open a document and try again.");
    } 
    
    function MakeJPEGfile() {
         for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++) {
    
              if (myDoc.pages.item(myCounter).appliedSection.name != "") {
                   myDoc.pages.item(myCounter).appliedSection.name = "";
              }
              var myPageName = myDoc.pages.item(myCounter).name;
              var myJpegPrefix = "";
              var isStyleExist = true;
    
              //Checking the existing of the paragraph style (filename)
              try {
                  myDoc.paragraphStyles.item("filename");
              }
              catch (myError) {
                  isStyleExist = false;
              }
    
              if (isStyleExist)
                myJpegPrefix = getParagraphContent(myDoc.paragraphStyles.item("filename"), myDoc.pages.item(myCounter)) + myPageName;
              app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
              app.jpegExportPreferences.exportResolution = 72;
              app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.exportRange;
              app.jpegExportPreferences.pageString = myPageName;
    
              var myFilePath = "~/Desktop/" + myJpegPrefix + ".jpg";
              var myFile = new File(myFilePath);
              myDoc.exportFile(ExportFormat.jpg, myFile, false);
         }
    }
    
    // The new function, but needs to add checking the file name rules.
    
    function getParagraphContent (paragraphStyle, currentPage) {
        var paragraphContent = "";
        for (var c = 0; c < currentPage.textFrames.length; c++) {
            for (var i = 0; i < currentPage.textFrames.item(c).paragraphs.length; i++){
                if (currentPage.textFrames.item(c).paragraphs.item(i).appliedParagraphStyle == paragraphStyle) {
                    paragraphContent = currentPage.textFrames.item(c).paragraphs.item(i).contents;
                    return paragraphContent;
                }
            }
        }
        return paragraphContent;
    }
    

    Lack of check file naming rules.

Maybe you are looking for