Sort file by date

hi guys, i have a problem with sorting my files here. this is what my code look like. but i could sort it
if any one knows please help me
          for ( count = 0; count < dirList.length; count++ )
          //return the character after the ('.')
          String fileName = dirList[count].getName();
          int index = fileName.lastIndexOf('.');
          //sorting the file
          long[] date = new long[dirList.length];
          for ( int i = 0; i < dirList.length; i++ )
               date[i] = dirList.lastModified();
          for ( int j = 0; j < dirList.length; j++ )
//i have a problem here...how do I sort these files by their date
          if (date[i].equalsTo(dirList[count]) );
               //Arrays.sort(dirList);          
          }//end of the loop of sort
          }//end for innerloop for date     
                    if ( index >= 0 )
                         newString = fileName.substring(index, fileName.length());
                    out.print("<!--" + newString + "-->"); //debug
                         if ( newString.equalsIgnoreCase( ".txt"))
                              out.println("<a href='http://10.0.0.16" + dirList[count].getPath().substring(9) + "'target='right'>" + fileName + "</a><br>");
                         }// end if newstring;
               }//end if index
          }//end for
thank so much for your help.

if i've understood your question correctly, you have an array of File objects, and you want to sort them according to their "last modified" times. here's how you can do that, in chronological order:Comparator fileByLastModified = new java.util.Comparator() {
  public int compare( Object o1, Object o2 ) {
    java.io.File f1 = (java.io.File) o1;
    java.io.File f2 = (java.io.File) o2;
    long time1 = f1.lastModified();
    long time2 = f2.lastModified();
    if ( time1 < time2 ) {
      return -1;
    if ( time1 > time2 ) {
      return 1;
    return 0;
Arrays.sort( dirList, fileByLastModified );

Similar Messages

  • JFileChooser: Sort files by Date

    Hi, all
    I watched that a JFileChooser has not a listener registered on the Table-Header(when the details-View is selected) to sort files by their attributes (name or date). Is there an extension of JFileChooser whish does it?
    Please post me any useful link or whatever
    Thanks, Thanasis

    Hmm, not entirely straightforward according to http://forum.java.sun.com/thread.jsp?forum=57&thread=449111

  • Sort files by date before 1950

    I wonder if anyone tried to sort old pictures by 'date created', prior to 1950. Bridge cs3 just ignores the date and will not sort.
    When managing old pictures from the 40's and earlier, it is just impossible to do that with Bridge.
    Any clue or reaason why this 1950 wall?
    Thanks,

    Here is a link on "date created" that gives some discussion on subject. Not sure it will answer your question but may give you some additional info on dates and sorting.
    http://www.adobeforums.com/webx/.3c05f330/10

  • Sort files in Finder Column View?

    Like to sort files by date in column view, is this possible? I know you can do it in List view, but can't seem to do this in column view. It would have to be folder specific, as the upper level (which are folders of folders) should be alphabetical, then the folder with files I'd like to sort by date created. Now, all are presented in alphabetical order, and then I have to scroll down to get to them.
    Thanks!

    Nope, can't be done in Finder column view - alphabetical is the only option.
    You can submit a feature request here:
    http://www.apple.com/macosx/feedback/

  • Is Bridge supposed to sort raw files by date modified?  Not on my systems.

    I have just installed photoshop/bridge cs5 on two windows 7 systems, home premium 64 bit, one an i3 chip and the other an i7 chip.  I was formerly using cs3.
    I see that Bridge is not sorting my raw files by date modified like it did before.  It sorts jpg files okay.  I noticed that the xmp files associated with the raw files, when I hover over them in Windows Explorer show the correct modified date but the thumbnail icon shows only creation date, which I assume is as it shou ld be.  Why doesn't Bridge CS5 sort raw files by date modified as it did in CS3?  CS3 must have referred to the xmp file modified date to use for sorting, I would think.
    I should also mention that the metadata file does not show the correct date modified, but gives the same date as the creation date.  Also the thumbnails for raw images that have been modified correctly show the icon that indicates it was modified.
    Also, I see that when you hover over a thumbnail in Bridge CS5 nothing is revealed about the file.  In CS3 Bridge hovering over a thumbnail showed several pieces of data about the file including anything in the file info.
    Is this just how Bridge CS5 works or have I missed a setting somewhere in Bridge or Windows?

    Curt, thanks for your response.  The tool tips
    was not checked and did result in "hovering"
    working.  I'm not sure why that's called tool tips, but okay.
    I have just installed the software in the last
    few days.  I almost immediately got an update
    notice and installed the update.  I thought I was
    up to date.  Then, just a while ago I got another
    update notice.  After installing it the sorting
    now works.  Thanks much.  Problems seem to be solved.

  • Why is Firefox suddenly sorting windows Files by Date?

    I may have changed a setting without knowing with some keystroke command, but suddenly yesterday Firefox started sorting my files in Windows (when I go to upload a file) by date modified. I tell it to sort by name but each time I go back it has defaulted to sorting by date again. This is really annoying.
    == This happened ==
    Every time Firefox opened
    == Yesterday

    I may have changed a setting without knowing with some keystroke command, but suddenly yesterday Firefox started sorting my files in Windows (when I go to upload a file) by date modified. I tell it to sort by name but each time I go back it has defaulted to sorting by date again. This is really annoying.
    == This happened ==
    Every time Firefox opened
    == Yesterday

  • How Can I put an Artists Live Albums in a separate folder, so they sort by "Concert Date" in iTunes and do not "intermingle" so to speak with Studio Albums?  Is this possible?

    How Can I put an Artists Live Albums in a separate folder, so they sort by "Concert Date" in iTunes and do not "intermingle" so to speak with Studio Albums?  Is this possible?
    That is about the best way I can phrase my question.
    I put year/month/date at the beginning of a show, hoping for them to sort by date and I get mixed results.
    Would creating a Folder within the Artists' existing folder  that said "Pearl Jam Live", inside the "Pearl Jam" folder in iTunes Media help this "Date Sorting Issue"?
    Thank you.

    Or is there a way to go through aperture to make a new reference library that I can move the masters into later?
    you do not move the masters into a references library - you turn your current library into a referenced library.  As Terence Devlin said:
    File -> Relocate Masters
    What you should set up:
    Select a folder, where you want to store your referenced files - probably on an external drive.
    Decide on a hierarchical folder structure inside this folder - that is completely up to you.
    Select a project from your library and use the command "File -> Relocate Masters/Originals" to move the original image files to the folder where you want to go them to. Only take care not to send two projects to the same folder.
    Alternatively, if you do not care about the folder structure Aperture will use, select all images at once from the "Photos" view and let Aperture decide how to assing the folders - in the "Relocate Originals" dialoge you can specify a subfolder format.
    Regards
    Léonie

  • How do I delete duplicate songs in my iTunes? I have hundreds and I don't want to delete them one by one. They were all added on the same date, so sorting by the date won't help.

    How do I delete duplicate songs in my iTunes? I have hundreds and I don't want to delete them one by one. They were all added on the same date, so sorting by the date won't help.

    Hi, if this is in regards to your library simply open up itunes and do the following steps:
    Click File
    Scroll down to "show duplicates"
    A list will then appear of your duplicate song titles.
    Be sure to CAREFULLY review each song to make sure it is a duplicate ( as I have some music that is the same song but live, acoustic etc...)
    Proceed to manually delete each song from the list and leave alone any song that you wish to keep.
    Best of luck,
    Cait

  • Cannot sort files in bridge cs4

    Hi
    As you know it, since Windows XP xp2, the explorer sorts the files this way :
    1, 002, 03, 000004...
    For getting back the "right" alphabetical way, you can change the registry. So did I.
    Now in the explorer, I get the files sorted like this :
    000004, 002, 03, 1
    Well
    but in adobe bridge CS4, nothing changes. the files are sorted : 1, 002, 03, 000004...
    Is there a way to have the files sorted like in explorer ?
    thanks for your replies
    (Sorry for my bad english)

    Yes it can be done but it's very messy!
    The following script should do the job BUT it does require you select Manual sort and move any document first! This makes sure that a hidden file .BridgeSort is created in the folder. This file is re-created into the correct order then a new window is opened and the old window closed. This is because Bridge only reads this file when it opens.
    Using ExtendScript Toolkit copy and paste the code into a new window, start Bridge - Edit - Preferences - Startup Scripts, click the "Reveal" button. This will open the folder that the script should be placed. Once that has been done close and restart Bridge and accept the new script. You will now have a new menu item "AlphaSort"
    #target bridge  
    if( BridgeTalk.appName == "bridge" ) { 
    var newMenuSort = new MenuElement( "menu", "Alpha Sort", "after Help", "mySortData" );
    var newSortCommand = new MenuElement( "command", "Alpha Sort", "at the end of mySortData" , "xxxx" );
    newSortCommand.onSelect = function () {
       alphaSort();
    function alphaSort(){
    var file = new File(app.document.presentationPath +"/.BridgeSort");
    if(!file.exists){
        alert("Please select manual sort and move one document before running this script!");
        return;
    file.hidden=false;
    file.open('r');
    var data = file.read();
    file.close();
    data = data.split('\n');
    var Items=[];
    for (var a in data){
        if(data[a].match(/item/g)) Items.push(data[a]);
    app.document.sorts = [{ name:"file-size",type:"dimensions", reverse:false }];
    Items = Items.sort();
    try{
    file.remove();
    file.open("w", "TEXT", "????");
    }catch(e){alert(e+" - "+e.line);}
    $.os.search(/windows/i)  != -1 ? file.lineFeed = 'windows'  : file.lineFeed = 'macintosh';
    file.writeln("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>");
    file.writeln("<dirinfo>");
    file.writeln("<files>");
    for(var s in Items){
        file.writeln(Items[s]);
    file.writeln("</files>");
    file.writeln("</dirinfo>");
    file.close();
    file.hidden=true;
    app.document.sorts = [{ name:"user",type:"date", reverse:false }];
    app.document.chooseMenuItem("mondo/command/new");
    app.documents[0].close();

  • How to use XmlModify to sort the XML Data?

    Hello,
    I saw some examples explain how to use XmlModify in BDB XML package. I want to sort the XML data by several elements but my Java program could not work correctly.
    <CustomerData>
    <Transaction>
    <DLSFIELDS>
    <ADR_PST_CD>12345</ADR_PST_CD>
    <CLT_IRD_NBR>002</CLT_IRD_NBR>
    </DLSFIELDS>
    </Transaction>
    <Transaction>
    <DLSFIELDS>
    <ADR_PST_CD>12345</ADR_PST_CD>
    <CLT_IRD_NBR>102</CLT_IRD_NBR>
    </DLSFIELDS>
    </Transaction>
    // many nodes like transaction ...
    </CustomerData>
    My XQuery script was executed successfully in the shell. The script looks as follows:
    "for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD), xs:decimal($i//CLT_IRD_NBR) return $i".
    The Java code :
    // create XmlManager
    XmlManager manager = // ...;
    // open XmlContainer
    XmlContainer container = // ...;
    XmlQueryContext context = manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Eager);
    XmlQueryExpression expression = manager.prepare("for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD),xs:decimal($i//CLT_IRD_NBR) return $i", context);
    XmlModify modify = manager.createModify();
    XmlUpdateContext uc = manager.createUpdateContext();
    XmlDocument xmldoc = container.getDocument("sample.xml");
    XmlValue value = new XmlValue(xmldoc);
    long numMod = modify.execute(value, context, uc);
    System.out.println("Peformed " + numMod     + " modification operations");
    Could you point out the errors above or offer some suggestion?
    Thanks.

    I have other question of the sorting issue. Here are a large XML need to sort so I have to split it to multiple small XML files. After importing these files, I will use the XmlModify and XQuery to sort them. I'm not clear on the multiple XML files processing.
    1. Can the BDB XML ensure that all these XML files were sorted or how to update all documents with same logic.
    2. If I want export all these sorted documents, how can I ensure these files processed in sequence? Which document needs process first?
    The export method:
    public void export(String outputfile)throws Exception{
    final int BLOCK_SIZE = 5 * 1024 * 1024; // 5Mb
    try{
    File theFile = new File(outputfile);
    FileOutputStream fos = new FileOutputStream(theFile);
    byte[] buff= new byte[BLOCK_SIZE];                         
    XmlResults rs = container.getAllDocuments(new XmlDocumentConfig());               
    while(rs.hasNext()){
         XmlDocument xmlDoc = rs.next().asDocument();
         XmlInputStream inputStream = xmlDoc.getContentAsXmlInputStream();                    
         long read=0;
         while(true){
         read = inputStream.readBytes(buff, BLOCK_SIZE);
    fos.write(buff,0,(int)read);                    
         if(read < BLOCK_SIZE) break;
    inputStream.delete();
    xmlDoc.delete();
    rs.delete();
    //MUST CLOSE!
    fos.close();               
    catch(Exception e){
    System.err.println("Error exporting file from container " + container);
    System.err.println(" Message: " + e.getMessage());
    Thanks.

  • Sort by Creation Date and TIME!

    I need to sort hundreds of images taken by three photographers and on six different cameras. I sort by Image Date, but it keeps each photographers images together, seems to sort by DATE only, then by file name.
    I have used iView Media Pro to sort this way and it is a GREAT way to organize this type of work. Is there a way to refine how Aperture 1.5.1 does this type of sort?
    At this point, my option appears to be to export my final picks, then resort and rename them in iView Media Pro.

    In the browser section, I clicked on the list view (control-L is the shortcut) and then clicked on the "Image Date" header, and saw all my images sorted by date AND time. Is this what you're looking for? If all the photographers shot on the same date and time, then they'd be intermingled I suppose, but if the times were separated, this should work. Give it a shot anyway.
    Mark

  • HT2905 Most all of my 1700 songs have been duplicated in iTunes. I have downloaded the instructions how to delete the duplicates but it says "sort by the date you added" and i have no column that says that. I am running windows xp.

    Most all of my 1700 songs have been duplicated in iTunes. I have downloaded the instructions how to delete the duplicates but it says "sort by the date you added" and i have no column that says that. I am running windows xp.

    Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
    Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created.  If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
    Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
    (If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
    tt2

  • Import and Management of Video Files by Date Still Broken

    It really is very disappointing that after 3 versions, and 110 bug fixes, basic things like importing or managing a video file by date is still completely broken.
    Even more troubling, is that for someone who uses LR3 this is a very obvious problem, and should be very easy to fix.
    When you import a file on a wide range of cameras the date that is used for the video file as far as LR3 is concerned is the date you are importing it, not the date it was taken. This makes any management of the file, especially when managed next to pictures, very difficult.
    The problem, as far as I can tell, is that in Windows, a file has both a 'Date Created' and a 'Date Modified'. 'Date Created' is whenever the file was created on the PC. If you bought a new computer and transferred a bunch of files over on 30/12/2010, all of your files will have a 'Date Created' that is 30/12/2010 regardless of when the photos or videos were taken. Or if you take a video on September 1st and import it onto your computer September 15th, it will have a 'Date Created' of September 15th.
    'Date Modified' however lists the date that the file was last changed. For video files, that most likely was the date the video was shot.
    Every program I have ever used for video files has always organized them by Date Modified (when organizing them by date). For example, its the default in Windows 7 Explorer when showing video files, all the video files listed by the date you have taken them. Date Created really doesnt have any useful information.
    Its inexplicable to me why LR3 uses Date Created instead of Date Modified. It is a glaring error, that should be easily fixed. Microsoft can manage to do it right, as a byproduct in its OS, Im not sure why an imaging company in a $400 piece of specialist software cannot.
    And just in case this is overlooked as a minor problem, it certainly is not. It happens to the following cameras:
    D90 (first camera to shoot video)
    D3s (thought by many to be the best low light camera)
    D7000 (likely to be Nikon's most important DSLR)
    D3100 (likely to be Nikon's most purchased DSLR)
    Canon S95 (one of 2 most popular P+S for DSLR owners)
    Fuji 31fd (Ill never forget you!)
    And those are just the cameras I have on my desk, Im sure it happens to many others.
    Also, when importing these files by date, LR3 will import them into a folder 1 date later then the date that LR3 is using for the file. So, just to be clear, you could take a video on May 1st, import it into LR3 on May 2nd and LR3 would say it was taken May 2nd, and it would be placed in the folder for May 3rd.
    Im really not sure why something so basic has not been addressed in so long, and it makes any sort of managment of video files by date in LR3 useless.
    Very disappointing.

    I agree that the wrong file system date is being used. But I scanned all my Lightroom files (manually) tagged with 'video'. When the file contains suitable metadata with a capture time that is used. When that's missing, the (wrong) file system date is used.
    Interestingly I even found one camera where the dates were originally right (in 2009), then disappeared for a while (probably due to a firmware upgrade!) and then came back again. Summary of what I found:
    Very old (Philips) webcam / format AVI / no metadata visible / wrong date
    Canon Powershot A80 / format AVI / metadata visible / right date
    Nokia N73 cellphone / format MP4 / no metadata / wrong date
    Canon EOS 5D Mark II around 2009 / format MOV / metadata visible / right date
    Canon EOS 5D Mark II around 2010 / format MOV / no metadata / wrong date
    Canon EOS 5D Mark II around 2011 / format MOV / metadata visible / right date
    So my conclusion is that the camera makers are making a bit of a mess when they introduced video. Nikon introduced its video a year or so later than Canon. I don't know if "no metadata" means that there is none, or that Adobe just doesn't like the format. But given the pattern of the firmware updates with Canon, it looks like Canon and Adobe ultimately agreed on the format. But in any case Lightroom (I am using 3.4.1) has a bug w.r.t. its fallback scenario of reading file system dates.
    In my case, the dates changed when I copied all my data from one disk (old NAS) to a new one (new NAS). It is disconcerting that you get the copying date despite comparison tools declaring the files to be identical (Beyond Compare 3 also keeps an eye on date differences).
    Hope this helps, Peter

  • How can I sort pictures by date and than by time stamp ?

    The approx. 2.000 pictures was taken by two cameras.
    Both cameras intern date and time where adjusted before the for session.
    It seems that Aperture 3.3.1 can´t manage it, can it?
    In the browser there is only one common field for date and time.
    I shoot the picture with two Canon 5D Mark II and Mark-III in JPG and RAW mode.
    The file name only is totally confusing for sorting.
    Like IMG_0008, _MG_0022 for Mark-II
    and
    _L2A8410 for Mark-III.

    Hi,
    I am not sure, which sort order you want to achieve? If you sort by the date field, the images will be sorted chronologically, ascending or descending, according to date and time - isn't what what you want?
    Can it be that you have a time zone problem? Compare the dates on the images that should be sorted side by side.
    Unless you specify "Camera Time" and "Actual Time" on import, Aperture will assume that the camera time has been your current system time.
    Canon 5D Mark II and Mark-III
    And unfortunately, both your cameras are exactly the two cameras that I know, where the time zone correction in Aperture is buggy and does not have much effect. I cannot find the discussion again right now, but look for a thread by Frank Caggiano on time zone correction.
    Regards
    Léonie

  • Moving multiple files by date range and/or file name filtered

    I need to move multiple files by date range and/or by filename (using a filter) to another directory. 
    OR
    How can I get the attributes of files in a directory, something you would see when typing in "dir" in a DOS or ls in UNIX.  I can parse this info and then make a array of files to move.
    The reason for needing this is that I need to move files that are located in another country, and sort them into different directories based on date.  Having to read each file for it's file information adds wasted time that I can't afford.  I am about to create a dos terminal to do a "dir" command to get the information and parse it out.. but I was hoping LV had a function that can get me that info so I don't have build it.
    THanks.

    You should use the 'File/Directory Info' functionality.
    This will return the last modificatoin of the file.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

Maybe you are looking for

  • Nokia lumia 1520 loud speaker grinding sound and w...

    hi, my nokia lumia 1520 has been making sound grinding sounds which can only be heard if you put your ear close to the loud speaker. i emailed the company that i bought the phone from and this is what they said: "for this type of issue, you can do a

  • Accounting document was creted with a mandatory condtion missing

    We have an invoice that creates a FI document with a pricing error. This is a one-time case but we would like to understand why it happened. Invoice has a pricing error. Mandatory YTRC is missing but despite this, the FI document was created. We iden

  • SRM or ECC number vendor number in mdm catalogue

    Hi All, I have few question regarding Business partner in Catalogue: 1.Suppose for the same vendor, SRM business partner number is different from ECC number, then what would be the business    partner I should maintain in MDM catalogue ? Will it be S

  • Bug? Unable to add ActionListener using Anonymous class.

    Hi, I come accross one strange behaviour while adding ActionListener to RCF component. I am trying to add the ActionListener in the managed bean using the Anonymous. We can add the actionListener to a button using following methods. I am talking abou

  • Dvd is jumpy

    I burned a dvd with images from imovie and the photos are fluttering slightly on the dvd. Otherwise, the photo quality is great with no pixilation. I had created the project in idvd and dragged in the movie. Previously, I had reduced the size of the