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.

Similar Messages

  • Can I append date to the file name using Bursting

    Hi All,
    I know that we can append date to the file using %y, %m and %d for
    Email
    FTP
    WEBDAV
    But is there any way of appending the date to the file name if I am bursting my file to a shared location.
    I tried that %y, %m and %d but that doesn't work for bursting.
    Please reply
    Thanks,
    Ronny

    If this requirment is for EBS, please refer the following blog
    http://blogs.oracle.com/BIDeveloper/2010/08/xdoburstrpt_passing_parameters.html
    For standalone see the following delivery sql query as example.
    select
    d.department_name KEY,
    'Standard' TEMPLATE,
    'RTF' TEMPLATE_FORMAT,
    'en-US' LOCALE,
    'PDF' OUTPUT_FORMAT,
    'FILE' DEL_CHANNEL,
    'C:\Temp' PARAMETER1,
    d.department_name||'_'||to_char(sysdate,'mmddyyyy')|| '.pdf' PARAMETER2
    from
    departments d
    Thanks
    Ashish

  • HT203164 How do I fix a problem when downloading cd into iTunes, "the file name is invalid or too long"? I have never had this problem before until recently.

    The message "the file name is invalid or too long" pops up when I try to download a cd onto iTunes. I never had this problem before but lately it has been happening. What can I do to fix this?

    iPhoto Menu ->
    Preferences ->
    Accounts ->
    Delete and recreate your email settings.
    Alternatively, use Apple's Mail for the job. It has Templates too - and more of them.

  • How to add YYMMDD format date to the file name

    Hi,
    I need genrate the file with date suffixed to its name in YYMMDD format. The add time stamp is adding it till YYYMMDD-HHMMSSS.
    How can I change this format to the required one? Any suggessions.
    Thanks.
    Sri

    hi,
    you can create the whole filename (whatever you need)
    in the mapping (in a UDF) using adapter specific message attributes
    there are many blogs describing how to do that Dynamic Configuration of Some Communication Channel Parameters using Message Mapping
    Regards,
    Michal Krawczyk

  • Import From Folder: How to Extract the File Name in a Custom Column.

    Hello All
    Here´s what we´re trying to do:
    We have a folder with csv files named like this:
    Sales_2013-02-05.csv
    Sales_2013-02-04.csv
    Sales_2013-02-03.csv
    Sales_2013-02-02.csv
    Sales_2013-02-01.csv
    And in the csv files there are the sales columns but not the date column.
    So we want to extract the date from the file name.
    I´ve tried entering = Source[Name] in a custom column, but it adds a "LIST" link, and on a click on expand, it adds ALL file names from the folder in each row, instead of just the needed one.
    If we could get the proper file name in each row (from where they got extracted), we could split the column and get the date from there. But I don´t know how put the filename there properly.
    Can you help?

    This isn't entirely straightforward, but it's definitely possible. What you need to do is to apply all of your transforms to each individual file instead of the combined files. I do that as follows:
    1) Use Folder.Files as generated by the GUI to look at the list of my files.
    2) Pick one file and do all the transformations to it that I want to apply to all of the files. Sometimes, this just amounts to letting the autodetection figure out the column names and types.
    3) Go into the advanced editor and edit my code so that the transformations from step 2 are applied to all files. This involves creating a new function and then applying that function to the content in each row.
    4) Expand the tables created in step 3.
    As an example, I have some files with names that match the ones you suggested. After steps 1 + 2, my query looks like the following:
    let
        Source = Folder.Files("d:\testdata\files"),
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        #"Imported CSV" = Csv.Document(#"d:\testdata\files\_Sales_2013-02-01 csv",null,",",null,1252),
        #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
        #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
    in
        #"Changed Type"
    For step 3, I need to take steps 3-5 of my query and convert them into a function. As a check, I can apply that function to the same file that I chose in step 2. The result looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        Loaded = Loader(#"d:\testdata\files\_Sales_2013-02-01 csv")
    in
        Loaded
    Now I apply the same function to all of the rows, transforming the existing "Content" column into a new value:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader})
    in
        Transformed
    Finally, I need to expand out the columns in the table, which I can do by clicking on the expand icon next to the Content column header. The resulting query looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader}),
        #"Expand Content" = Table.ExpandTableColumn(Transformed, "Content", {"One", "Two", "Three"}, {"Content.One", "Content.Two", "Content.Three"})
    in
        #"Expand Content"
    From here, you should be able to get to what you want.

  • How to read the file name....

    Hello all,
    I have a doubt on reading file name.
    I have 10 pdf files in the dir '/d01/tem/'
    I need to get/load those 10 file names using PL/SQL. Meaning I need to get the file names only not the file contents...
    Please help me to achieve this....
    Thanks and Regards,
    Muthu

    There is no public synonym for DBMS_BACKUP_RESTORE, so you need to prefix it with SYS and make sure your user has execute privilege on the package. This will fix call to DBMS_BACKUP_RESTORE, but you have another issue. - fixed tables. Only SYS can read them. You'd have to login as SYSDBA, create a view around x$krbmsft and grant select on it to your user.
    SQL> connect sys as sysdba
    Enter password:
    Connected.
    SQL> grant execute on DBMS_BACKUP_RESTORE to scott;
    Grant succeeded.
    SQL> create view v$krbmsft as select * from x$krbmsft;
    View created.
    SQL> grant select on v$krbmsft to scott;
    Grant succeeded.
    SQL> connect scott
    Enter password:
    Connected.
    SQL> set serveroutput on
    SQL> DECLARE
      2      p_directory VARCHAR2(1024) := 'C:\TEMP';
      3      p_null VARCHAR2(1024);
      4      i number := 1;
      5  BEGIN
      6      SYS.DBMS_BACKUP_RESTORE.searchFiles(p_directory, p_null);
      7      FOR x IN (select fname_krbmsft fname from sys.v$krbmsft) LOOP
      8        DBMS_OUTPUT.PUT_LINE(x.fname);
      9        EXIT WHEN i = 3;
    10        i := i + 1;
    11      END LOOP;
    12  END;
    13  /
    C:\TEMP\acbrd-0050.csv
    C:\TEMP\afiedt.buf
    C:\TEMP\A_3136_4000.log
    PL/SQL procedure successfully completed.
    SQL>SY.

  • How to create Dynamic field so it appears the file name

    Hi,
    I was wondering if anyone knows how to create a dynamic text field so it automatically appears the file name created of the document.
    thanks alot !!!
    Jack
    [email protected]

    Hi, Seems we can't upload examples anymore, but here is a screen shot of what I meant.
    Hope it helps

  • When I try to open a pdf link in my browser I am asked where I want to save the file.  I used to be asked if I wanted to open the file.  How do I get back to being asked if I want to open rather than save?

    When I try to open a pdf link in my browser I am asked where I want to save the file.  I used to be asked if I wanted to open the file.  How do I get back to being asked if I want to open rather than save?

    What browser?

  • How can I save the web page by using the Page Title as the file name ?

    When i use Internet Explorer ,I can save the web page by using Page Title as the file name(as default no need to adjust anything). But when i use Firefox ,It can not use the Page Title to save as the file name. How can I do that like in Internet Explorer?

    See:
    *File Title: https://addons.mozilla.org/firefox/addon/834
    *Title Save: https://addons.mozilla.org/firefox/addon/712

  • Cannot save as PDF - "Could not save a copy as (filename) because the file is already in use..."

    I have a number of PSD files I've created and I'm trying to save them as PDFs.
    I can Save for Web and Devices, I can save as a .gif, .eps., and every other format I've tested, but I cannot save as a PDF. I get the error:
    "Could not save a copy as (filename) because the file is already in use or was left open by another application."
    I'm running Adobe Master Collection CS5 with Photoshop CS 5.5 (12.0.4 x64) on a Windows 7 64-bit machine.
    I have a 928 GB HD with 697 GB free.
    I have rebooted and tried saving the files immediately after I reboot. I have killed my virus scanner. I have killed a number of other possible culprits including Acrotray.exe and CS5ServiceManager.ext
    I have run Process Explorer as recommended by Microsoft and found no applications using the file. I've also tried saving the file to my external hard drive and/or renaming the file with only rare luck.
    Nothing seems to fix it.
    The boards seem to suggest Adobe isn't taking responsibility for this and pointing it back to the OS or other software. I'm willing to believe them if someone can show me how/where to kill whatever process it is - but at this point, all my indicators point back to Photoshop.

    Here is a clip from a past post where user could not drag and drop files to hard drive.
    To my great relief I have now sorted this issue and offer the following as the Correct Answer. My sincere and grateful thanks go to Curt and Yammer, above, who have helped me so much in sorting this Windows 7 issue which is clearly very relevant to Bridge users also. Any slowness to grasp what they have been saying is down to me!
    The key to solving this issue lies is understanding that in terms of Windows 7 Security, every internal or external hard drive, plus folders, sub-folders and files thereon has an OWNER. Also each OWNER has a certain level of PERMISSION to do things such as moving files to a different folder, deleting or re-naming them etc. If you try to do things that you don't currently have Permission to do, that is when you get an ‘Access Denied’ error message. Also your system has an Admistrator or Administrators and at the outset you need to ensure through the Control Panel that you are listed as one of them. .
    If, like me, you didn't realise these things, (and why would you if Microsoft or your computer or hard drive suppliers couldn't be bothered to really make sure you knew about them), then trying to fathom the ‘Access Denied’ problem becomes a stressful and frustrating nightmare as I can testify having spent a week at it!
    The steps that I took to resolve the issue and which I believe now constitute the 'Correct Answer' are as follows:
    First make sure that you have Administrator rights on your system via the Control Panel
    Next ‘right click’ on the Drive whose files you want to gain full access to, for example the drive that your pictures are stored on, and click on 'Properties'.
    Under the Security tab you will see a list of Groups and Users on this drive and the Permissions that they have to do things.
    Before doing anything to edit these Permissions, first click on the Advanced button. This opens another window with a tab showing the Owner of this drive.
    Click on the Owner tab and if you are not already listed as the owner, make yourself the owner by selecting your name from the list. I believe it should appear there if you are an admistrator or user. (In my case at this stage the owner was initially shown as an obscure string of numbers and letters which I believe identified the drive when it was connected to the lap top I was using before I upgraded my machine)
    Now be sure to check the box that says "Replace Owner on Subcontainers and Objects" and the click Apply. On completion of this step, the drive in question and all the folders, subfolders and files thereon should now be 'owned' by you. You could check this out by right clicking on a particular folder then clicking Properties > Security > Advanced > Owner. Your name should appear. So far so simples!
    Now go back to the Security Tab for your drive (Step 2 / 3 above) and look at the Permissions you currently have. Your aim now is to allow yourself 'Full Control.' If you don’t currently have this level of permission click Edit, select your name on the list, check ‘Full Control’ and 'Apply' the change.
    I think I'm right in saying that at this point whilst still working in the Drive directory you are now given the option of ticking boxes which allow you to, in effect, cascade the permission you have just granted yourself to all the files and folders on that drive. Tick the box to allow this and Windows should then take care of the rest.If I'm not quite correct here then in my particular case, for example, all my images were stored on my external drive. The top level, or 'parent' folder in which all my pictures could be found was the 'My Pictures' folder and I had created a number of folders and subfolders ('child ' folders) within that folder. The permissions I gave to the Parent folder – My Pictures – were cascaded down through the Child folders.
    On completion of the above step I tested the result in Windows Explorer by dragging a few files back and forth between folders and it now worked perfectly - I was now able to move / delete / rename etc all files without now getting the dreaded access denied message. What a sense of relief! This meant that I could now open Bridge normally rather than having to right click it and 'Run As Admistrator' - albeit that is a very useful thing to do until you get the problem sorted as described.

  • Does anyone know how to use pages so you can export pdfs from the internet and automatically drag words from the document into the file name of the pdf (i.e., author, title of a scientific paper)

    Does anyone know how to use pages so you can export pdfs from the internet and automatically drag words from the document into the file name of the pdf (i.e., author, title of a scientific paper). For example, if I am downloading a paper by smith called "Surgery" that was published in 2002, it will automatically set the file name in the download to smith- surgery 2002. I have heard pages is smart enough to do this.
    thank you

    Pages can export only its own documents. They may be exported as PDF, MS Word, RTF or Text files.
    Pages can import (ie. Open a file as, or Insert a file into, a Pages document) documents in several formats, but won't rename the document as you describe. Documents that can be Opened (eg. Text, AppleWorks 6 WP, MS Word files) are converted to Pages documents, and retain their original names, with .pages replacing the original file extension. Files that can be Inserted (generally .jpg, .pdf and other image files) become part of the existing Pages file and lose their names.
    It may be possible, using AppleScript, to extract the text you want and to Save a Pages file using that text as the filename, but that would depend in part on being able to identify which text is wanted and which is not.
    How will the script determine where the author's name begins and where it ends?
    How will the script recognize the beginning and of the title, an decide how much of the title to use in the filename?
    How will the script recognize the year of publication?
    For papers published in a specific journal, with a strict format for placing each of these pieces on information, or containing the needed information as searchable meta data in the file, this might be possible. But it would require knowledge of the structure of these files, and would probably handle only papers published in a specific journal or set of journals.
    Outside my field of knowledge, but there are some talented scripters around here who might want to take a closer look.
    Best of luck.
    Regards,
    Barry

  • I accidently created files using a Free Trial version of InDesign. Now the files are gone. Where did they go? How do I get them back? I pay for this service...

    I accidentally created files using a Free Trial version of InDesign. Now the files are gone. Where did they go? How do I get them back? I pay for Creative Cloud... but used the wrong login apparently.

    Files you save don't disappear, even if you no longer have the software that created them. They're right where you saved them.

  • Using Javascript & Actions to resize an image and add the filename as text

    Hello,
    I am currently working on a way to take an image, resize it and add exactly what is in it's file name (before extension) as a text layer. I have succeded in this BUT am having issues with file names that require more than one line of text.
    I need the text to align to the bottom of the image & the script or action must then resize the image so that the text does not overlap.
    Any ideas on how this can be done?
    At the moment I am using:
    -"Fit Image.jsx" to resize my image to a specific size (This was included in the Photoshop CS5 scripts)
    - A script to add the file name without extension and place the file name at a specific position.
    AdFileName.jsx
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.PIXELS;
    try
      var docRef = activeDocument;
      // Now create a text layer at the front
      var myLayerRef = docRef.artLayers.add();
      myLayerRef.kind = LayerKind.TEXT;
      myLayerRef.name = "Filename";
      var myTextRef = myLayerRef.textItem;
      // strip the extension off
      var fileNameNoExtension = docRef.name;
      fileNameNoExtension = fileNameNoExtension.split( "." );
      if ( fileNameNoExtension.length > 1 ) {
       fileNameNoExtension.length--;
      fileNameNoExtension = fileNameNoExtension.join(".");
      myTextRef.contents = fileNameNoExtension;
      // off set the text to be in the middle
      myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
      myTextRef.size = 12;
            myTextRef.font="Arial-BoldMT"
            //set position of text
            myTextRef.justification = Justification.CENTER;
            myTextRef.kind = TextType.PARAGRAPHTEXT;
            myTextRef.width= docRef.width;
            myTextRef.height= docRef.height/ 2;
            myTextRef.position= [0, docRef.height * 0.88];
    catch( e )
      // An error occurred. Restore ruler units, then propagate the error back
      // to the user
      preferences.rulerUnits = originalRulerUnits;
      throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );
    Can the position be changed to allow more rows of text but keep it aligned with the bottom of the layer?
    How can I script in a way to make the image resize based on the amount of text lines?
    Any help would be greatly appreciated.

    You can add a text layer any where the only thing you need to worry about is the size of the font you use.  You can normally calculate a font size by saving the images resoltuion and then setting its resolution to 72 DPI calculate a font size basied of the images pixel width and the number of characters you want in a line. After adding the text layer you can restore the image to its original resolution and align the text layer by making a selection and alignint the text layer to the selection.  There are nine posibilites like the positions in the selection you can align to like a tick tack toe board. You need to use a script to add the text layer because your retrieving the filename.  The positioning of the text layer could be done easily in an action the would use the scriot to add a text layer the do a select all  the align the added text layer to the selection.
    About your script don't make text paragraph just add new line characters to make a multi line text layer So it can be positioned easily
    I do just that with my stampexif action.  The action uses my stampexif Photoshop java script to add a multi line text layer containing some formatted EXIF data then the action centers the text layer and add a layer style to it. Link http://www.mouseprints.net/old/dpr/StampExif.jsx Example

  • I recorded an interview on my iPad using the iTalk app. How can I transfer that audio to my MacBook Pro? The file is too big to email.

    I recorded an interview on my iPad using the iTalk app. How can I transfer that audio to my MacBook Pro? The file is too big to email.

    Use DropBox. https://www.dropbox.com/help/84/en
     Cheers, Tom

  • I am using OSX 10.9.5 and Outlook Web App for emails. When I download an attachment it replaces the space in the file name with   - how can I change this?

    I am using OSX 10.9.5 and Outlook Web App for emails. When I download an attachment it replaces the space in the file name with %20  - how can I change this?

    Click on the below link :
    https://get.adobe.com/flashplayer/otherversions/
    Step 1: select Mac OS  X 10.6-`0.`0
    Step 2 : Safari and FIrefox
    Then click on " Download Now"  button.

Maybe you are looking for

  • How to fill the error stack

    Hi, we want to check the data quality of the source in the start routine, process the good in the target and the bad in the error stack. Have you any idea which exception I have to raise to put it in the error stack? regards, Adrian

  • Error in solving MultiSchema.sqlj

    Hello there, I am trying to solve Multischema.sqlj example given in sample examples of sqlj with slight moditications. My emp table is having scott schema and dept table is having sheetal schema. The compilation fails at #sql (deptCtx) { SELECT dname

  • 10.6.4 problems

    Earlier today I installed the 10.6.4 update, and the Sarafi update. Upon restarting the machine I noticed that some settings had been erased/changed: 1. Date/Time: "Your computer's clock is set to a date before Ja 1, 2008..." My clock is set for 5:10

  • 96 hours to build a blue-ray project???

    Hi again, just taken a look of my project running and I felt my heart in my throat!!!!!! 96 hours to build a project!!!!!!!!!!!!!! It is a BR project, edited in two languages and it is 2 hours and 10 minutes long. Everything (filmed menus and main fi

  • I bought a show on itunes and when i try to sync it with my ipod touch 2nd gen. it says cannot be played on this ipod. any suggs?

    any help is appreciated