Generate file names randomly

are there anyways to generate file names randomly? if there are, are there any reference codes i could refer to? thanks.
heard that using random characters from ascii code (generating random numbers and translating them into chars) could do the job but i am rather new to it. can anybody advise me on how to go about it? thanks.

There is a method called createTempFile in the java.io.File class for this purpose. I suggest you use that one.

Similar Messages

  • Filespaces in generated file names - unfortunate

    I'm trying to upload all the files generated by an export to directory. Many of the auto-generated file names use the name of a page (which is displayed in the navigation - so i don't want to remove the spaces).
    This creates files with blanks in the name, and most FTP implementations will choke on this.
    #1 - this should be fixed
    #2 - does anyone have a workaround for managing this?

    Spaces are not valid in web pages. If used, they have to be escaped with %20
    If you want to change the names of files before trying to use them with some web publishing program, this shell script might be of use. It changes spaces to _ makes upper case letters lower case, etc.
    #!/bin/bash
    # Pete keeps giving me photos with bad file names
    for i in *
    do
    OLDNAME="$i"
    NEWNAME=`echo "$i" | tr ' ' '_' | tr A-Z a-z | sed s/-/-/g`
    if [ "$NEWNAME" != "$OLDNAME" ]
    then
    TMPNAME="$i"_TMP
    echo ""
    mv -v -- "$OLDNAME" "$TMPNAME"
    mv -v -- "$TMPNAME" "$NEWNAME"
    fi
    done

  • When someone other than myself downloads an image from my web album, a dynamically generated file name replaces the original file name.  How I can prevent the original file name being replaced during the downloading process?

    When someone other than myself downloads an image from my web album, a dynamically generated file name replaces the original file name.  How I can prevent the file name being changed during this downloading process?

    Hi Glenyse,
    Here are my steps.
    1.  I upload multiple image (jpg) files onto my photo album.
    2.  I select the "sharing" by email option for this album.
    3.  I enter the recipient's email address.
    4.  The recipient receives my message and clicks on the link.
    5.  The recipient accesses my photo album and clicks on one of the images.
    6.  The image opens up to its own screen.
    7.  The recipient selects the "download" and then save file option.
    Here is the part I do not understand.  For some reason, during this "download" process, the original name which I have given to the file is replaced by different name.  So I was hoping that someone knows how to prevent the file name from being changed during the "download and save" process.
    Much appreciated if you can help me find a solution to this problem.
    Mary  

  • How to generate file name dynamically in receiver FIle adapter? Please help

    Dear Experts,
       I have a scenario where I need to generate output file with the name dynamically pulled from the XI payload.
       In receiver File communication channel I don't see any option where we can specify the XML path for the file name.
       For example:
       If my inbound XML structure (inbound interface) is like below:
       <filename>file123.txt</filename>
       <RootNode>
             <Element1>Product123</Element1>
       <RootNode>
      From this I need to pick the filename value and generate the output file with the same value.
      How can I achieve this? Please help!
    Thanks & Regards
    Gopal
    Edited by: gopalkrishna baliga on May 3, 2011 1:10 PM

    Gopal,
    You can use DynamicConfiguration class for this.
    You need to write UDF for this and with input of filename you want to set and map this UDF to the top level node.
    Refer the below famous blog from Micheal:
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    You can also use Variable substitution to get value from payload, search SDN on this.
    --Divyesh Vasani

  • Dynamically generating file names for 2 File ( 1: 2 mapping transformation)

    Hi ,
    I have a scenario Proxy to File(FCC) with 1:2 transformation in message mapping ie 1 sender and 2 receiver interface ....
    1 Message mapping
    1 Operation mapping
    1 RD , 1 ID and 2 file receiver channels  and 2 receiver agreements.
    I need to dynamically generate the filename say abc.(first 9 characters of mesg id) and xyz.(first 9 characters of mesg id)
    I used dynamic configurations with ASMA settings, created 2 UDF assigned each of these to header node of r receiver message types.
    Here, I guess the second dynamic configuration is over writing the first dynamic configuration and hence creating only one file with xyz.(first 9 characters of mesg id)
    name .
    Need your valuable inputs
    Thanks and regards,
    Pavithra

    As dynamic configuration doesnot work in case of 1:n mapping what  you need to do is
    Create a field Filename in your source data structure
    Create a1:1 mapping between your source structure and source structure
    In that 1:1 mapping on the target structure assign UDF for file name
    Now this target structure will be used as a source structure in your next 1:2 mapping
    Under operation mapping add first the 1:1 mapping for source and then the multimapping
    regards
    Ninad

  • Generating file name with date

    Hello,
    I try to create via ABAP a file name with date in it. Normaly my script must run but the script won't run. Please help. Thanks.
    data = sy-datum.  " = data set to sys date
    data+6(2) = '01'. " = first day of month
    data = data - 1.  " = last day of last month
    file name creation
    p_filename+0(21) = '/sapio/flatfiles/xxx/'. " = first part of file name
    p_filename21(6) = data0(6). " = second part of file name
    p_filename+27(15) = '_XXXX_XXXXX.csv'. " = last part of file name
    p_subrc = 0.
    Regards, Thomas

    Hi again!
    Now I try it with your hints but now I got a save error.
    program conversion_routine.
    * Type pools used by conversion program
    type-pools: rsarc, rsarr, rssm.
    tables: rsldpsel.
    * Global code used by conversion rules
    *$*$ begin of global - insert your declaration only below this line  *-*
    * TABLES: ...
    * DATA:   ...
    data: data like sy-datum.
    *$*$ end of global - insert your declaration only before this line   *-*
    form compute_flat_file_filename
         using p_infopackage type rslogdpid
      changing p_filename    like rsldpsel-filename
               p_subrc       like sy-subrc.
    *       Insert source code to current selection field
    *$*$ begin of routine - insert your code only below this line        *-*
    * Datum wird gebaut
    data = sy-datum.  " = data set to actual date
    data+6(2) = '01'. " = first day of month
    data = data - 1.  " = last day of month before
    v_date = data+0(6).
    * Dateiname wird gebaut
    p_filename = '/sapio/flatfiles/XXX/'v_date'_XXXX_XXXX.csv'.
    p_subrc = 0.
    *$*$ end of routine - insert your code only before this line         *-*
    endform.

  • Mailing the Report Output-Does not generating file name

    Dear Gurus,
           The below program fulfils the "mailing the report" requirement .it sends the out put as an attachment in XLS format.But one problem exists i.e.,it does not generate  filename.It gives the filename as ".XLS"(DOT XLS).
    What should be done that system generates a filename?
    *& Report  ZTESTMAIL                                                   *
    REPORT  ZTESTMAIL                               .
    tables: ekko.
    parameters: p_email type somlreci1-receiver.
    types: begin of t_ekpo,
    ebeln type ekpo-ebeln,
    ebelp type ekpo-ebelp,
    aedat type ekpo-aedat,
    matnr type ekpo-matnr,
    end of t_ekpo.
    data: it_ekpo type standard table of t_ekpo initial size 0,
    wa_ekpo type t_ekpo.
    types: begin of t_charekpo,
    ebeln(10) type c,
    ebelp(5) type c,
    aedat(8) type c,
    matnr(18) type c,
    end of t_charekpo.
    data: wa_charekpo type t_charekpo.
    data: it_message type standard table of solisti1 initial size 0
    with header line.
    data: it_attach type standard table of solisti1 initial size 0
    with header line.
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
    t_contents like solisti1 occurs 0 with header line,
    t_receivers like somlreci1 occurs 0 with header line,
    t_attachment like solisti1 occurs 0 with header line,
    t_object_header like solisti1 occurs 0 with header line,
    w_cnt type i,
    w_sent_all(1) type c,
    w_doc_data like sodocchgi1,
    gd_error type sy-subrc,
    gd_reciever type sy-subrc.
    t_object_header = 'Text.xls'. append t_object_header.
    *START_OF_SELECTION
    start-of-selection.
    Retrieve sample data from table ekpo
    perform data_retrieval.
    Populate table with detaisl to be entered into .xls file
    perform build_xls_data_table.
    *END-OF-SELECTION
    end-of-selection.
    Populate message body text
    perform populate_email_message_body.
    Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'PO'
    changing gd_error
    gd_reciever.
    Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp aedat matnr
    up to 10 rows
    from ekpo
    into table it_ekpo.
    endform. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    Build data table for .xls document
    form build_xls_data_table.
    *CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
    *con_tab TYPE x VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
    con_tab type c value cl_abap_char_utilities=>horizontal_tab,
    con_cret type c value cl_abap_char_utilities=>cr_lf.
    concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    loop at it_ekpo into wa_charekpo.
    concatenate wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    endloop.
    endform. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    form send_file_as_email_attachment tables pit_message
    pit_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
    data: ld_error type sy-subrc,
    ld_reciever type sy-subrc,
    ld_mtitle like sodocchgi1-obj_descr,
    ld_email like somlreci1-receiver,
    ld_format type so_obj_tp ,
    ld_attdescription type so_obj_nam ,
    ld_attfilename type so_obj_des ,
    ld_sender_address like soextreci1-receiver,
    ld_sender_address_type like soextreci1-adr_typ,
    ld_receiver like sy-subrc.
    ld_email = p_email.
    ld_mtitle = p_mtitle.
    ld_format = p_format.
    ld_attdescription = p_attdescription.
    ld_attfilename = p_filename.
    ld_sender_address = p_sender_address.
    ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
    w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle .
    w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
    clear w_doc_data.
    read table it_attach index w_cnt.
    w_doc_data-doc_size =
    ( w_cnt - 1 ) * 255 + strlen( it_attach ).
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle.
    w_doc_data-sensitivty = 'F'.
    clear t_attachment.
    refresh t_attachment.
    t_attachment[] = pit_attach[].
    Describe the body of the message
    clear t_packing_list.
    refresh t_packing_list.
    t_packing_list-transf_bin = space.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 0.
    t_packing_list-body_start = 1.
    describe table it_message lines t_packing_list-body_num.
    t_packing_list-doc_type = 'RAW'.
    append t_packing_list.
    Create attachment notification
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 1.
    t_packing_list-body_start = 1.
    describe table t_attachment lines t_packing_list-body_num.
    t_packing_list-doc_type = ld_format.
    t_packing_list-obj_descr = ld_attdescription.
    t_packing_list-obj_name = ld_attfilename.
    t_packing_list-doc_size = t_packing_list-body_num * 255.
    append t_packing_list.
    Add the recipients email address
    clear t_receivers.
    refresh t_receivers.
    t_receivers-receiver = ld_email.
    t_receivers-rec_type = 'U'.
    t_receivers-com_type = 'INT'.
    t_receivers-notif_del = 'X'.
    t_receivers-notif_ndel = 'X'.
    append t_receivers.
    call function 'SO_DOCUMENT_SEND_API1'
    exporting
    document_data = w_doc_data
    put_in_outbox = 'X'
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = 'X'
    importing
    sent_to_all = w_sent_all
    tables
    object_header = t_object_header
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    exceptions
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    others = 8.
    Populate zerror return code
    ld_error = sy-subrc.
    Populate zreceiver return code
    loop at t_receivers.
    ld_receiver = t_receivers-retrn_code.
    endloop.
    endform.
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
    wait up to 2 seconds.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    Populate message body text
    form populate_email_message_body.
    refresh it_message.
    it_message = 'Please find attached a list test ekpo records'.
    append it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    Your suggestions will be appreciated and rewarded.
    Thanks in advance
    Murali

    Hi
    Your pgm is not passing anything in obj_descr in packing list for excel file. If you pass a name your excel file will have that.
    Regards
    Sathar
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'PO'
    ' '  *------> no value*
    changing gd_error
    gd_reciever.
    form send_file_as_email_attachment tables pit_message
    pit_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription *----> no value*
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
    t_packing_list-obj_descr = ld_attdescription.

  • Generating File name as versions

    Hi,
    I have a scenario where in my output file should be generated in versions or sequence.
    order_00.xml and nest file as order01.xml so on for every file posted ..
    My receiver is a 3rd party system and we are using FTP not NFS..
    Any help in achieving this would be appreciated.

    Hi,
    Instead of going with the sequence number, it would be better to go with the IDOC number.
    Here is the code:
    public String putDynamicConfiguration(String docnum, Container container) throws StreamTransformationException{
    try
         DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
         DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
         String filename = "Prefix_" + docnum + ".txt";
         conf.put(key, filename);
         return docnum;
    catch (Exception e)
         return docnum;
    you can add a counter function to thiis code to achieve the requirement.
    Thanks,

  • Can I change the File Names the Iphone generates for my photos so I don't have to go and "rename" each photo?

    When I take a photo the phone stores it with a self generated file name, however since I have multiple Iphones taking photos, I would like to change the method of this generated filing system.
    As an example, photos being taken with Iphone #1 would have Phone1Image1... or some smaller if necessary and then phone 2 would be Phone2Image1...
    Then when I go into the cloud I could sort them according to source rather than a random date selection or some other way of filing.
    Thanks

    Just have each song as a separate playlist.
    You can use the SpotLight search on the iPod to find songs as well as other things.
    You can also change what the search shows to only include music. Go to Settings>General>Spotlight search

  • Reg : I need to generate a file name sequence number.

    Dear All,
    I need to generate file name in sequence number. Now i have generated file in specific folder. In that folder file i am reading one by one and generating. Problem is folder file some names having special characte those names are not generating while reading 'Cat' Caommand in shell script. Instad of that i want to generate files in 1.ldt,2.ldt to etc..
    Please guide me how to generate in specific folder.
    Thanks in advance.
    Best Regards,
    Velu.

    First, LabVIEW 7 allows you to pass string and path data types directly into the Matlab script node. Otherwise, in LV <= 6.1 you can do the following:
    In LabVIEW, convert the string to an array of U8s using the String to Byte Array function. Then pass the U8 array into the Matlab script node as a Real Vector type. Finally, in Matlab, convert the Real Vector to a string using the char() function. For example:
    stringAsString = char(stringAsRealVector)
    Attached is an image that shows how to do this.
    Good luck,
    -Jim
    Attachments:
    Matlab_Script_Node_String_Input.GIF ‏6 KB

  • How to Change the defalut file name of PDF out of report (Version 6i)

    Dear All
    I have a report which opens from forms(Version 6i); the output of the report is in PDF. The generated file name is the same name as the report. Is there any way to give parameter name of the report as the name of the PDF out put of the report?
    For example I have a parameter called PATIENT_ID and my value is 25613 now I need the PDF out put name also 25613.
    Thanks and regards
    Sijo

    Use DESNAME to specify the output filename:
    set_report_object_property(repid, REPORT_DESNAME, :patient_id);

  • Dynamic File name in FTP Communication Channel

    Hi All,
    We have requirement where ,we create a filenames dynamically ( runtime).These filenames whihc do change for every execution needs to be added in FTP communication channel.
    1. How can we add the this generated file name in FTP CC Communication Channel.
    2. Does this file needs to part of target structure during graphical mapping ?
    3. Can we also dynamically append the Directory name to file names aswell ?
    Please provide your valuable sugestions.
    Thanks for your support.

    1. How can we add the this generated file name in FTP CC Communication Channel.
    3. Can we also dynamically append the Directory name to file names aswell ?
    to get the FileName:
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    To get the Directory:
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    Then append:
    key+key1
    And then in the CC select the Directory checkbox under the ASMA properties...
    2. Does this file needs to part of target structure during graphical mapping ?
    The file which is sent using the CC will have the FileName as configured in the UDF of the graphical mapping....and if i am not wrong then the target structure resembles the file (if there is no FCC done)....
    Regards,
    Abhishek.

  • Dynamic file name creation problem

    Hi Friends,
                      I had a requirement where i had to generate file name at target side with the following format
    " raw_text_yyyymmddhhmmss.txt" . This can be acheived by using "currentdate" function but there is no field at target side which holds this value, if there was a field then i would have used variable substitution method to generate the file name.Another option is Dynamic Configuration UDF already
    my root node is mapped to some src field say FLD1 based on which i will be getting multiple files.
    How to customise this udf to get current date as filename for multiple target files:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    String Outputfile = conf.put(key,a);
    return Outputfile;
    Regards,
    Vinod.

    Hi Nityanand,
                          Your solution is right but actually problem here is recently a slight change was made for file name it should be "raw_text_yyyy-mm-dd-hh-mm-ss.txt"  by using variable substitution we get file name as this format "raw_text_yyyymmddhhmmss.txt"  .
    @Prateek: I cant give Currentdate as direct input to udf becoz we are generating files based on a certain field from source side.We are sorting this multiple source fields and generating target files.
    Any suggestions.....
    Regards,
    Vinod.

  • F110 file name configuration

    Hi experts,
    I would like to know how to find the configuration of generated file name in F110? Path is taken from DME variant, but filename in AL11 has following format: posting date_ runId_BUKRS_payment method_00. I would like to change it, thank you in advance.
    Best regards
    Paul Smuda

    HI,
    Use substring function in the mapping and give the the values as 5 and 8.
    Map to the any field in the Target Structure.
    Use the variable substitution in the Receiver File adapter.
    Go throgh the following blogs.
    Dynamic File Name using XI 3.0 SP12 Part - I
    Dynamic file name(XSLT Mapping with Java Enhancement) using XI 3.0 SP12 Part -II
    Dynamic File Name depending on the Source File name
    Dynamic File Name - Suppress the Substitue varible
    Solution to the problem encountered using Variable Substitution with XI-SP12
    Regards
    Goli Sridhar

  • BIG PROBLEM: CSS files not loading because of international characters in file name

    I have Muse Beta 7 in Spanish.
    The program creates a css file called master_a-página-maestra.css in css folder. It is referenced in the resulting HTML code here:
    <!-- CSS -->
      <link rel="stylesheet" type="text/css" href="css/site_global.css?3951792836"/>
      <link rel="stylesheet" type="text/css" href="css/master_a-p%c3%a1gina-maestra.css?fileVersionPlaceholder"/>
      <link rel="stylesheet" type="text/css" href="css/index.css?3948175564"/>
    When you work locally in your Windows formatted har drive, everything looks fine, but when you upload your files to a server, everything is screwed up. The server doesn't recognizes the URL and returns an error page, resulting in style errors in the entire site.
    This can also happens with html files if the title of the page contains international characters or with images if the image file name in your Hard Drive contains international characters.
    I already pointed out long time ago Muse was generating file names with international characters like á, ñ, etc but nobody cared about it. Too bad. I had to activate file name customization but I think that Muse should replace automatically this characters in the same way that it replaces other conflictive characters like commas or ampersands.
    This is not a fault of the FTP client. Accented characters are not web safe regardless of the FTP client you are using. It is a server side issue. Some servers support it some others don't. I don't mind if it works in Adobe Catalyst server because the final website is going to be in another server and maybe next year when paid hosting is ended the client may move it to another server.
    It makes more sense to replace accented characters in file names by their not accented equivalents ('a' instead of 'á', 'N' instead of 'Ñ', etc) and avoid all this problem.

    Zak, It is funny you mention it, because the site I am talking about is hosted in 1and1. try this: http://www.artofwalls.com/rosannawalls/biografía.html
    As you can see, the offending "í" in the file name causes 1and1 server to throw a "page not found" error. And this has happened with many other servers I have tried since.
    Muse boast of generating code fully compatible with all major web browsers but by using international characters in file names it ggenerates code suitable only for very few web servers. International characters have been always a no-no for internet URLs. Internet was designed by people who didn't care about ascii codes beyond 127 so using international characters in html file names is just call for problems.
    "to work with your hosting provider to determine how to enable Unicode encoded (UTF-8) file names and HTML files on their servers" is not a viable solution most of the time unless you are a Very Important Client of your host provider. If not, making changes means money for them and if you are the only one who complains, they are going to just tell you to not use international characters in your names.

Maybe you are looking for

  • Java.io and applets

    I have about 20 ascii files that my applet will read when a certain button is pushed. The buttons have the names of 7 of the major files on them. I want to add files to the server but not change the code. I have been able to do this from a local mach

  • How to dynamicly scroll a text area?

    Hi, i put my JTextArea on top of a JScrollPane. i want to set the JScrollPane scroll to the end of the JTextArea everytime i do textArea.append(someString); is there an easy way of doing this? or i have to program the logic? Thanks.

  • Auto nat vs manual nat

    Some how I have ended up with multiple network objects for the same network example obj-192.168.1.0 obj-192.168.1.0-1 obj-192.168.1.0-2 All are for the same network but have different nat statements. When I look at my NAT statements I have a bunch of

  • Use of Oracle pump utility as equivalence of SQL bcp utility??

    can anyone throw any pointers to how to use Oracle pump utility as equivalence of SQL bcp utility??

  • Ok so i baught a macbook 2 weeks ago

    and now they have upgraded the macbooks. is it possible to return mine so i can get the better one for the same price. i find it not fair that i baught this expecting to have the most recent model and now i do not. is there anything that can be done