Results 1 to 9 of 9
  1. #1
    flyboynm is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default file rename based upon creation date?

    Is there a way to use Java to rename a file based upon the creation date? Something like DNC1.jpg getting renamed to 20131114DNC1 because it was taken on Nov 14, 2013 is what I mean. My wife and I take a ton of pictures with our digital cameras and the default way of naming the file is the same between the cameras and is hard to figure out which file goes with what.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: file rename based upon creation date?

    The File API has a lastModified method.
    However, there's no guarantee that that will be the date the image was taken, rather than simply the date the file was created on your system.
    It might be a valid date if it's still on the sd card, and both camera and pc clocks match.

    That information is stored inside the jpg itself and, having recently looked into the same sort of thing myself, it's not a simple thing to access. Indeed I shelved it for the time being, as I was unable to read the meta data successfully. I was going to look for some freebie software to do the job of organising the images, but haven't got round to that yet.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,083
    Rep Power
    6

    Default Re: file rename based upon creation date?

    A google for "java jpeg creation date" provides some very interesting results though, such as this stackoverflow thread:

    How to get date picture created in java - Stack Overflow
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: file rename based upon creation date?

    I looked at that one, but didn't get round to getting it to work (time limitations and all that).
    Might give it another go at some point, as I still haven't found a package that does what I want.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    flyboynm is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: file rename based upon creation date?

    Tolls, I tried to get it to run but haven't gotten it to work either. :(

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: file rename based upon creation date?

    What does your code look like?

    I had another shot this morning (need to do something at the leisure centre while waiting for the kids to finish their various activities). Seem to have got it to work this time.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    flyboynm is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: file rename based upon creation date?

    To be honest, I have gotten code for displaying the file creation date and code for moving a file based upon resolution. I have combined them together in an attempt to get it working. If I can do that, I can get the rename function going pretty easily. I also want to copy the files to a directory based upon the date of creation which I have already done the pseudocode and foresee that being a trivial thing to do once I get the rename of files going. I can post both sets of code for the above if you would like.

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: file rename based upon creation date?

    Oh, so it does work then.
    That's OK.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    flyboynm is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: file rename based upon creation date?

    When I posted that, I had tried it once and it had,not worked. I went back about a hour later, saw the problem and got it working. Brain fart was the issue.

Similar Threads

  1. Replies: 5
    Last Post: 10-17-2012, 10:07 AM
  2. Replies: 4
    Last Post: 07-27-2011, 11:57 AM
  3. How to print the creation date of a jar file
    By lunarbof in forum Advanced Java
    Replies: 9
    Last Post: 08-22-2008, 06:12 PM
  4. How to rename a file
    By Java Tip in forum java.io
    Replies: 0
    Last Post: 04-05-2008, 10:11 AM
  5. How to Rename a File
    By Ada in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 12:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •