Incrementally name file with saveAs

Hello all,
I am trying to create a script that names the active file as w1.pdf, and then subsequently would name the file w2, etc.
If one were working on w9.pdf and ran the script, you guessed it..........w10.pdf
Can I use the increment operand with saveAs? All of my efforts just keep adding stuff to the file name, not incrementtally changing the file name.
Thanks in advance for any help,

Hello Kent,  Yes of course this can be done.  But of course it has to be done from a folder level script, since the saveAs function cannot be used from a document script.
The basic technique is to acquire the file name, determine whether or not it matches the expected format, and parse out the current number.  Then increment the number and generate a new file name.
For example, this code uses a regular expression to perform the task:
// Match "w" followed by one or two digits
var rgFlNm = /^w(\d{1,2})/;
if(rgFlNm.test(this.documentFileName))
   var newFileName = "w" + (Number(RegExp.$1) + 1).toString();
   this.saveAs(newFileName);
else
   app.alert("File Name does not match expected format");
the code here displays an alert if the file name format does not match "w" followed by one or two digits.  But you could have it default the file name 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 most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Similar Messages

  • How to download  file with Save As dialog

    I am trying to download files with a Save As dialog, according to Jason Hunter's instructions in Jave Enterprise Best Practices.
    String filename = "content.txt";
    // set the headers
    res.setContentType( "application/x-download" );
    res.setHeader( "Content-Disposition", "attachment; filename=" + filename);
    // send the file
    OutputStream out = res.getOutputStream();
    returnFile( filename, out);
    The file content.txt is in the root directory of my webapp. But I get this stack:
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.io.FileNotFoundException: content.txt (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.(FileInputStream.java:64)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.returnFile(FileDownloadServlet.java:43)
         at com.interwoven.cssdk.examples.servlets.FileDownloadServlet.doGet(FileDownloadServlet.java:24)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:484)

    The root of the webservers changes from server to server and
    sometimes it depends on the path you run webserver exe.
    The best i have found to overcome this kind of problems is by
    using getResourceAstream() method which basically looks at classpath locations only, but still this has some problems like it should kept at the
    specified classpath becoz the getResourceAsStrem() method is not static
    method and it always associated with the class object and the file
    accessing also should be in the same package/classpath.
    by using getResourceastream you cannot look at other places (except classpaths)
    and this should be used only if you looking for .properites definitions.
    the Second best method is
    see you have a file called "context.txt" right
    before you create a file, first create a directory at the root, let say
    "\tmp"
    and then create a file \tmp\context.txt
    and then open an output stream to it either using fileoutputstreamm...
    and then write all output content to servlet/client output stream.
    this will be the best becoz you are specifying the "\" the root
    and this is common for all operating systems and definitely it will create at the root directory either serverroot or harddiskdrives root
    so you will never missout and the exceptin will also not comes along the way
    cheers..
    if you get new thing , let me know
    bye
    with regards
    Lokesh T.C

  • Sql loader how import a file with save the actual row number in a db field

    Hey,
    how can i save the row number for each row in a file into a database field i the same table with the sql loader (sqlldr)?
    test data:
    john doe
    joe meier
    table:
    name surname line_number_in_file
    john doe 1
    joe meier 2
    and so on ... an if an line is discarded because it is empty for example it should be as this:
    test data:
    john doe
    joe meier
    table:
    name surname line_number_in_file
    john doe 1
    joe meier 3
    thanks for helpinmg and excuse my very bad english :-)
    Message was edited by:
    user527827

    but if one of the when clause faild or some rows are
    rejectet the sequence is not right.Did you read the link?
    "If a record is rejected (that is, it has a format error or causes an Oracle error), the generated sequence numbers are not reshuffled to mask this. If four rows are assigned sequence numbers 10, 12, 14, and 16 in a particular column, and the row with 12 is rejected, the three rows inserted are numbered 10, 14, and 16, not 10, 12, and 14. This allows the sequence of inserts to be preserved despite data errors. When you correct the rejected data and reinsert it, you can manually set the columns to agree with the sequence."
    also if you read multiple lines and they inserted in
    the wrong order the number from the sequence is not
    the line number...what do you mean with "reading multiple lines and wrong order?"

  • How do I save a file with SAVE AS rather than SAVE A VERSION?

    I have entered data on a template file and wish to SAVE AS a named file. Pages gives me only one option "Save a Version" which saves the template file overwritten. What has happened to "SAVE AS"

    Just discovered this "feature" myself and I'll also be filling in a feedback form to point out what an appalling idea this was.  When I read that "Save As..." has been totally removed, can't even be activated as an option, I shook my head.
    "Save As..." has been used in every program I can think of, cross-platform, for decades. It's as fundamental to the user experience as "Open File", "Close Window" or even "Save". It's like Apple deciding on a whim that a little cross is too boring for closing windows, let's make it a swirl instead - except users don't understand what it means.
    My main problem (and maybe someone here can help me with a workaround) is that I often open an old file and tinker with it, then decide I'm making more changes than I thought etc. and it might be better to keep the original and "Save As..." to create a new document. From what I can see, if I hit "Duplicate" I'll end up with 2 files that have my recent changes.  I'll then have to rename the new "Duplicate" file and go back and "Undo" all my recent changes in the original until I'm back to the start (or use "Revert").  Fail to see a way around this and it's such a fundamental problem that will literally hamper my use of Pages on a daily basis, that I'm seriously considering buying Word (what a horrible prospect!).

  • Is it possible to name files with YY instead of YYYY?

    Say there - longtime Lightroom user, consider switching to Aperture. I have 40,000+ images that are all named in the identical format - MMDDYY_001.JPG. I need to retain that file naming convention.
    One cool thing Lightroom did was allow me to rename a folder of images with varying capture dates with the file naming convention of MMDDYY. I didn't have to hard code anything, it inspected capture date dynamically and named the files accordingly (100510_001.JPG, 100610_002.JPG, 100610_003.JPG, 101310_004.JPG, etc).
    For the life of me, I can only see how to get Aperture to use MMDDYYYY, not MMDDYY. Is this not possible? I'd be astonished if it's not, and believe it or not, a potential deal breaker for me. I have no desire to use a 3rd party utility.
    Hopefully someone can show me that I'm blind or slow. Or maybe both.

    Hi. File this one under "Not the answer I was looking for".
    To the best of my knowledge there is no way in Aperture to create a preset with 2-character variable for year.
    There is, of course, a good reason behind this. Years are sequential, and people often sort by date or by year. The turn of the millennium forced everyone, and in particular computer users (remember Y2K?) to abandon the formerly-useful-and-now-misleading convention of 2-character abbreviations for year.
    For you, the move to Aperture means an opportunity to catch up. Rather than whittle Aperture down to fit your system, you might consider revamping your system. A program like Name Mangler makes short work of renaming 40,000 files. Change your convention to MMDDYYYY, and then take advantage of Aperture file naming.
    Two notes.
    - Unless you have a reason to sort on month (so that every photo taken in January, regardless of year, comes before every photo taken in February, and so on), you might revert to the standard YYYYMMDD so that a sort on file name will put your files in date order.
    - All photos in Aperture are already stamped with a date. That date is readily available. There is little reason to use the date in your file names. (Note too that Aperture (as well as Lightroom) does an excellent job of providing sorting, filtering, and grouping by date (and day, for that matter) -- just as the date is baked into your photos, date-organizing is baked into Aperture. So, if you are tempted, there is no reason to base your Library organization on date. Aperture already has all that built in.)

  • CS4 doesn't maintain place in file with save as

    In CS3 (and I think earlier versions, but I'm not sure), when I did a "save
    as" on a file and closed it, next time I opened it and it was at the same
    place of the file. I normally did this and the very end of a file and wanted
    to begin working in the same place when I opened it next. In CS4, I find
    that with the same process, next time I open it I am one page 1, not the
    end. Is there any way to get CS4 to open where the "save as" was on the last
    page instead?
    Thanks.
    Cyndee

    I don't doubt you at all, Cyndee.
    I've noticed quite a few small weird things myself.
    On many instances I can't use the welcome screen to open the first item
    on the list.
    The scroll wheel stops responding on occasion.
    I'm still having issues with the power zoom feature.
    There have been a smattering of reports of the toolbox being empty.
    Unfortunately none of these things has any rhyme or reason to them,
    making them difficult to fix.
    I suggest reporting a bug. Give them as many system details as possible.
    Bob

  • Import files with save copy to Microsoft Onedrive

    Now that Microsoft is offering Office 365 with unlimited Onedrive storage, I am planning to subscribe to the service. I would like to use the Onedrive space to be my tertiary backup storage for my photo files. (I have an external 2TB hard drive as the primary backup.) I have two questions regarding this service and file backup:
    1. Can anyone recommend a software package that would automatically synchronize in my computer and Onedrive? I was using Duplicati to copy files onto some Google storage I have, but that has ceased to work and I think it may be due to changes in Duplicati's software and sales model. This was not synchronization - it was a copy and backup function.
    2. If an automatic synchronization is not possible, I can certainly copy all of my existing files to Onedrive - though it would take a long time. Going forward, I would like to use the "create second copy" feature of Lightroom import to put copies of new raw files out on Onedrive. Has anyone successfully tried this and could they comment on the feasibility of doing this? 

    On your PC add the Folder where you have your images stored.  Add this folder location to your OneDrive Library. This should sync the entire folder.

  • Can't import RAW and psd file with same name different extension

    Trying to import a folder of images from desktop that I have been working with in Bridge CS3.
    LR won't import a RAW file that has a PSD file by the same name. Tried renaming the PSD and deleting the one with the same name, but says it is still there and won't import the RAW file - What is the correct workaround on this? Why can't it import same name files with different extensions?

    A forum search for 'RAW + JPEG' will give you more posts on this than you care to read. This will change. For now, import the RAW and PSD's from separate folders and then move them together for within LR.
    LR is seeing the RAW as a sidecar to the PSD. It is an unforseen effect of the RAW + JPEG thing where they decided to not import the JPEG, seeing it as basically a preview image for the RAW.
    LOL
    Don
    Don Ricklin, MacBook 1.83Ghz Duo 2 Core running 10.4.9 & Win XP, Pentax *ist D
    http://donricklin.blogspot.com/

  • How can I continuously auto-save and auto-name the JPEG files with a controlled time interval

    Hi,
    I am newly involved in some Labview projects that out of my knowledge. I am trying to save multiple JPEG images from a live imaging task to a folder in the computer hard disk every certain minutes. I'd like to name these files with the date and time (eg. Img_06012011_1635. jpg).Then, after hours long image capturing, I can have all the image files in a neat order.
    My goal is to have the jpg files auto saved and auto-named with the data and time at that moment. I also need to control this waiting time between each savings.
    Could you please show me some hints about this? See the vi attached, I know I need to do something on the "write path" part on the up right corner. Thanks!
    Solved!
    Go to Solution.
    Attachments:
    capture.vi ‏28 KB

    Thanks, Steve. When I built up a path with the date and time info and send them to the WriteJPEG File.vi like you mentioned, it stopped saving any files into the folder. Do you think this is the problem from my while loop?Could you show me if there is any other secret functions that restrains the file saving?
    I am planning to save the image files every 30 secs,for example, and then I can have a bunch of jpg files with their unique names after hours long image acquisition.
    I appreciate you kindly help!
    Attachments:
    capture(updated).vi ‏29 KB

  • There is no 'Save as' under the file menu.  How do I save a file with another name?

    Numbers help refers to the 'Save As' function in the File menu.  My version (latest) does not have a 'Save As' function.  How do I save a file with another name?

    Ross Millard wrote:
    Badunit. You have an original file and an edited file. Now you duplicate the edited file and save it with a different name. Now do you have to go and delete the changed file from which the duplicate had been made? And.... is the original still unchaned... still original?
    Ross,
    For the situation you describe, Apple has provided Duplicate and Revert. Use File > Duplicate to reach this menu:
    Regards,
    Jerry

  • How to save file with the "/" symbol in the name?

    Hi,
    I have Adobe Professional 8.  I need to save files with names that include the symbol /, but Adobe interprets, for example, A/88/6, as file name 6, in a folder named 88, in a folder named A, and sets up new folders to accommodate that.  I cannot substitute another symbol as I already have thousands of pdf files in a database using the / symbol, and I need them in the same folders.
    I would very greatly appreciate any advice,
    thanks,
    Mo.

    Thanks.
    As I said, I'm pretty ignorant about these things.  I wouldn't know how to begin using a "hack".  All I know is that I was able, for over a year, to save .pdf files directly from my browser on several computers, and use the forbidden "/" symbol in every file name.  After saving the files, Adobe will happily open them, and allow me to edit and re-save them, although I now see that it will not allow me to "save as" them under a different name without removing that symbol.
    I may not be tech-savvy, but I can state that everything I have said here and above is entirely accurate.  I would be happy to open a dropbox account to show you countless .pdfs with the symbol "/" in the name.
    This is honestly not that big a deal.  I greatly appreciate this discussion, and you have inspired me to become slightly less computer-ignorant.
    Hope you all had a great New Year.  I am still recovering.
    Cheers,
    Mo.

  • In Pages how do I save a file with another name

    In Pages how do I save a file with another name?

    I don't know if there is a less cumbersome way to do this (I'm still pretty new to Lion) but This is what I do - since "Save As" seems to be gone with Lion.
    I create a duplicate document - then click the red button to close the document - and a dialog box pops up and asks if you want to save the changes - I change the name in there and then save the file under the new name.
    You can also save the copy to the desktop - get info - and then change the name if the finder window.
    I copied this from the Pages help area. These help instructions were created pre-Lion I'm sure.
    Saving a Copy of a Document
    If you want to make a copy of your document—to create a backup copy or multiple versions, for example—you can save the document using a different name or location. (You can also automate saving a backup version, as Automatically Saving a Backup Version of a Document describes.)
    To save a copy of a document: 
    Choose File > Save As and specify a name and location.
    The document with the new name remains open. To work with the previous version, choose File > Open Recent and choose the previous version from the submenu.

  • How to save dynamically generated PDF files with proper file name?

    Hi,
    I need to save the pdf file with default name which generated by
    dinamically.
    this is the code i am trying to save by default
    protected void processRequest (HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    OutputStream bos = response.getOutputStream ();
    // this returns pdf byte array
    byte  ios[]  = callReport ( reportId_param , fullyQualifiedReportClassName , paramHashMap ) ;
    response.setContentType ("application/pdf");
    // reportId_param and reportName_param supplied from some where
    String docName =  reportId_param + "_" + reportName_param ;
    if( fromDate_req != null && toDate_req != null )
                    String dateStr = fromDate_req + "_to_" + toDate_req ;
                    dateStr = dateStr.replaceAll ( "/" , "_" ) ;
                    docName = docName + "_" + dateStr ;
    // here docName would be like "RP_COM_COLL_01_Message_Details_03_09_2008_to_03_09_2008"
    response.setHeader ("Content-Disposition","inline; filename=" + docName ) ;
    bos.write (ios);
    bos.flush ();
    }the above code produces pdf in browser when calling this URL
    http://localhost:8080/DAD01TN0801027/RWReportServlet
    In browser we can save this PDF by using two ways
    1. File -> Save As
    2. By using Save Icon within the PDF toolBar
    both the actions uses the file name "RWReportServlet" as default instead of using docName
    Can any one help me please
    Regards
    Sakthivel.

    That said, your code is not very efficient. You're storing the complete PDF file in memory. What if the PDF file is fairly large? And what if multiple users download multiple large PDF files simultaneously? Your server would run out of memory. Rather use InputStream instead of a raw byte[]. And preferably buffer it.
    You should also be setting the content-length header by the way.

  • How to save PDF file with predefined name?

    Hi,
    I am new in LiveCycle Designer. I have a requirement to save a PDF file with predefined file name. When user clicks a "Save as PDF" button, the fillable form is saved with the name from the form fields (e.g. FormID_UserID_Timesstamp...)
    I added a button (btnSavePDF) to the form (Control Type=Regular). Then I added an action with the Condition:"When button is clicked" and the Result: "Save the form". I got the JavaScripts it genreated:
      CoverPageForm.FormPage.btnSavePDF::click - (JavaScript, client)
    app.execMenuItem("SaveAs");
    When I tested it in Adobe Acorbat XI, I have option to save it as .pdf or other file formats. My questions is how can I save it with the predefined file name as a .pdf file, instead user has option to change the file name or change the file format? Can app.execMemuItem() method take other parameters?
    Thanks
    Sam

    You can't do it with app.execMenuItem. You can use the doc.saveAs method, but it has to be executed in a privileged context. For your application this means a folder-level JavaScript file that would have to be installed on each user's machine or with code in a certified PDF that the users chooses to trust to allow for privileged JavaScript execution.
    More information on the saveAs JavaScript method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.524.html
    and some sample code relevant to the folder-level JavaScript option: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.168.html
    All of the sample code shown is for a regular PDF, so you'll have to adjust slightly for using with an XFA.

  • Can't save any file with any name-InDesign CC

    can't save any file with any name-file DBTmp4376-863643269 is damaged (error code:0)
    InDesign CC, OS version 10.9.1
    I explored solutions to failure in background task alert which did not work. Been using adobe products since they came on the scene. Nothing like this. Please help.

    I'm using version 9.2.
    Yes, it started with a new file. Support gave me the solution to save it to my desktop which worked. When I put it back in the original folder and opened/save it would not save to that folder. Created a new folder and was able to open & save to the new folder. That seems to be a workable solution. How a folder can become corrupt is a bit scarey.
    In experimenting with solutions I received another error "failure in background task alert" and discovered CS5 problems with background task.
    However the solutions for CS5 did not work in my incidence.
    I sure would like to prevent this from happening again. If you have any insights please share them. Otherwise I will just accept the experience as another computer workaround and be thankful that I have it.
    Thanks for responding.

Maybe you are looking for