Get the file creation date

hi friends..
i searched many forums to get file creation date
i didnt get the solution but i found one program which execute
dos command and gets the output of that.
so using that program i developed a program to get the file creation Date & Time also
//getCreationDate.java
import java.io.*;
import java.lang.*;
public class getCreationDate {
public static void main (String args[]){
  try {
     // get runtime environment and execute child process
     Runtime systemShell = Runtime.getRuntime();
      BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Enter filename: ");
      String fname=(String)br1.readLine();
     Process output = systemShell.exec("cmd /c dir "+fname);
       // open reader to get output from process
     BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));
     String out="";
      String line = null;
      int step=1;
      while((line = br.readLine()) != null )
            if(step==6)
           out=line;
            step++;
            }          // display process output
      try{
      out=out.replaceAll(" ","");
      System.out.println("CreationDate: "+out.substring(0,10));
      System.out.println("CreationTime: "+out.substring(10,16)+"m");
      catch(StringIndexOutOfBoundsException se)
           System.out.println("File not found");
   catch (IOException ioe){ System.err.println(ioe); }
   catch (Throwable t) { t.printStackTrace();}
}

Following line should be modified to make it work on all platforms:
Process output = systemShell.exec("cmd /c dir "+fname);

Similar Messages

  • How can I get the File Creation Date OR Last modification date of the incoming file in my message?

    I need the Last Modification Date and the File creation date of the consumed file in my message, is it possible to do that using a custom pipeline component in decode stage or any other way? The FILE namespace have File creation time that actually gives
    the time the file was dropped in receive location, not the actual creation time. Also this namespace doesn't have the Last Modification Date.

    Yes,
    As per MSDN, "File.FileCreationTime" - "Defines the time that the file was written to the folder that is monitored by the File receive
    adapter."
    So for File Modified DateTime, only option I can think of is create a custom file adapter (updating the File Adapter code from SDK ..\SDK\Samples\AdaptersDevelopment\File Adapter) and access the received file with the code something like the following, which
    you give you the Last Modified date
    string sLastModifiedDate = File.GetLastWriteTime(path).ToString();
    If there are any business requirements which drives you this, then this the only way I can think of. Because you can access the file properties only in adapter, when it passes through adapter file is handled as stream and you will only have context properties
    to access the file related properties.
    If you're looking for implement this for any audit purpose or for your any technical purpose, then you can suggest some alternate than using File updated datetime.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • To get the file creation date

    Hi All,
            Can anyone tell me how to get the creation date of a file in SAP Directory.
      Is there any function module to do so.
    Thank You.

    I don't believe one exists. You may need to do a JNI call to get this.

  • How can I change the file creation date?

    I recently downloaded more than 1,000 photos from my vacation. I'm preparing to burn DVDs for a friend, and I noticed that when I copy the photos to the desktop, they don't all have the same date. I have read a couple of discussions here about the difference between photo creation date and file creation date, and I understand the difference. But something seems odd to me.
    For purposes of illustration, let's take two photos: "A" was taken with the camera in the landscape position (how one normally holds a point-and-shoot); "B" was taken with the camera held in the portrait position (rotated 90 degrees). The photos were taken on April 24, about three minutes apart, but not imported into iPhoto until May 19.
    In iPhoto, both files show the actual creation date. Yay!
    The problem is with the files after having been copied to the desktop.
    When copied to the desktop, the info panel for photo "A" shows April 24 for both the "created" and "modified" dates. Photo "B," however, shows May 19 for the "created" and "modified" dates.
    Apparently, when the "B-style" photos were imported into iPhoto, the app automatically rotated them so that they are viewed correctly (without having to turn your head sideways). This is a very nice feature, but the result is that the file date changes.
    Is there any way to change this? I want the DVD to show the date the photo was created, not imported to iPhoto. Picky, I know … but I'm like that. 

    Apparently, when the "B-style" photos were imported into iPhoto, the app automatically rotated them so that they are viewed correctly (without having to turn your head sideways). This is a very nice feature, but the result is that the file date changes.
    Correct.  Your camera has an Auto-Rotate feature. However, the camera does not actually rotate any pixels in the file, but instead flags it with an instruction: "Display me this way". This is a tag in the Exif metadata. When you import a file with this tag iPhoto creates a modified version. It does this because most of the apps that integrate with it -  email clients, word processors etc - simply don't understand this Exif tag. So if you used the shot in a word processing doc, uploaded it to many Web site etc, the shot would come out sideways.
    iPhoto has nothing to say about File dates. There are various file utilities that will edit the dates on Files
    http://www.macupdate.com/app/mac/11143/a-better-finder-attributes
    for instance. But there are otheers, search on  MacUpdate
    Regards
    TD

  • Get the File information(data) from Directory AL11.

    Hi Friends,
    I want to get the file data from the given particular directory(which maintained in AL11) in the selection screen.
    for listing the files from the directory, i used FM 'RZL_READ_DIR_LOCAL'. it displaying only files what ever in the given directory.
    But my requirement is to display the complete data in the file ( log file contents).
    please suggest me with relevant Function module or logic.
    Thank you.
    Regards
    Ramesh M

    HI,
    Try using function module:
    PARAMETERS:     p_fname    LIKE rlgrap-filename               .
    data l_path       TYPE dxlpath       .
    DATA: l_true       TYPE btch0000-char1.
    *-- F4 functionality for filename on Application Server
      CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
        EXPORTING
          directory        = '/usr/sap/input'
          filemask         = ''
        IMPORTING
          serverfile       = l_path
        EXCEPTIONS
          canceled_by_user = 1
          OTHERS           = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        p_fname = l_path.  ""Here p_fname is the parameter for the user to select the file from the application server
      ENDIF.
    PFL_CHECK_OS_FILE_EXISTENCE
      DATA: l_file       TYPE tpfht-pffile.
      CLEAR l_file.
      l_file = p_fname.    "Here p_fname is the parameter for the user to select the file from the application server
      CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'
        EXPORTING
          fully_qualified_filename = l_file
        IMPORTING
          file_exists              = l_true.
      IF l_true = space.
        MESSAGE e001(zmsg).
      ENDIF.
    Hope it helps
    Regards
    Mansi

  • Get a files creation date with UTL_FILE or DBMS_BACKUP_RESTORE.SEARCHFILES

    Hello gurus!
    I have a number of files in the filesystem and i need to find out the names and creation dates of these files. Please do not suggest Java as that is not an option.
    So far i get the names of the files from the SYS side with a procedure that I can call from the user side. The procedure returns an XML string:
    create or replace procedure list_directory(directory varchar2, retResultSet OUT VARCHAR2) is
         ns          VARCHAR2(1024);
         v_directory VARCHAR2(1024);
    BEGIN
          v_directory := directory;
          SYS.DBMS_BACKUP_RESTORE.SEARCHFILES(v_directory, ns);
          retResultSet := '<list>';
          FOR each_file IN (SELECT fname_krbmsft AS name FROM x$krbmsft) LOOP
              --DBMS_OUTPUT.PUT_LINE(each_file.name);
              retResultSet := retResultSet  || '<file>' ||each_file.name|| '</file>';
          END LOOP;
          retResultSet := retResultSet || '</list>';
    end list_directory;Question 1:
    Something like each_file.creation_date would be perfect but it seems like the filename is the only attribute available here from x$krbmsft. Am i wrong? Any other way on the SYS side to get the date?
    Question 2:
    On the users side i could use UTL_FILE to get filesize but not much more valuable information. Can i get the creation date somehow with UTL_FILE or similar?
    Any help is appreciated!

    Anyone got any ideas?Maybe a method as described in Re: Read all file names from Directory. may help (Shows also FileCreationDate).

  • How can I change the file creation date through Labview 2012?

    I want to change the format of the data stored in some text files, but I want the file dates to remain the same.  Currently, my program creates the files with new dates.
    Solved!
    Go to Solution.

    LabVIEW to my knowledge doesn't have native functions to do this.
    You can use .NET functions on Windows to get/set the CreationTime, LastWriteTime and LastAccessTime.
    See attached VI (LabVIEW 8.6)
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    dotNET File Timestamp.vi ‏14 KB

  • Creating folders based on file creation date

    Hi,
    I have a folder full of images and I am looking for an Automator workflow/app/script that can look at the files sequentially, read the creation date and then create folder name based on the file creation date (Year-Day-Month). Then move the file to the respective folder.
    Appreciate any input you can provide.
    Regards
    Tom Erik

    Open the AppleScript Editor in the /Applications/Utilities/ folder and run:
    tell application "Finder"
    repeat with this_file in (get files of window 1)
    set the_date to creation date of this_file
    set folder_name to ((year of the_date as string) & "-" & day of the_date & "-" & month of the_date)
    try
    make new folder in window 1 with properties {name:folder_name}
    end try
    move this_file to folder folder_name
    end repeat
    end tell
    (75533)

  • IPhoto file creation date inconsistencies during drag and drop

    I have noticed that if I drag and drop a photo from iPhoto to Finder, the file creation dates in Finder are inconsistent.
    (This question is related to drag and drop only and not File->Export, which always uses the export date and timestamp for the file creation date and thus does not suit my needs).
    TEST A -- If the EXIF DateTimeOriginated is 01/01/2013, and today's date is 03/03/2013, then:
    In some cases when I drag a file to Finder, the EXIF date is used as the file modification/creation date in Finder
    In some cases, today's date is used as the file modification/creation date in Finder
    In some cases, a date in between the EXIF date and today's date is used
    It appears that for case A1, these are files that do not have a modified copy.  That is, if you select the photo in iPhoto and then click "File" -> "Reveal In Finder", the "Modified File" choice will be greyed out.
    For cases A2 & A3, iPhoto has inexplicably decided to create modified versions of these files either today or sometime in the past.
    TEST B -- I have read that unexplained modifications are tied to the auto-rotate function in cameras, and it does seem to be the case when I performed the test below:
    Select a large group of landscape format photos (these would not have been auto-rotated), then drag and drop to Finder.  The file creation dates are set to the EXIF date
    Add some portrait photos to the group in (1).  Now the file creation date of ALL photos including the non auto-rotated photos are set to the current date
    The behaviour in B2 is clearly wrong, since the landscape photos should be the same as in B1.  This is bug #1.
    Furthermore, iPhoto appears to be inconsistent with when these modifications are made.  For example, I dragged & dropped an auto-rotated photo on 02/02/2013, then dragged & dropped it again today, then the file creation date in Finder (and also the date of the modified file in iPhoto, as shown in iPhoto File->Reveal In Finder->Modified File) can either the EXIF date (01/01/2013), the late of the last drag & drop (02/02/2013), or today's date (03/03/2013); there does not appear to be any rhyme or reason to this.  This is bug #2.
    In any case, saying "you should never use drag & drop in iPhoto" (as I have read in some other forum posts) isn't a solution, because Apple should either (a) support this function correctly or (b) remove it altogether.  Furthermore, I regularly burn photos to disk for others so having the file date and timestamps correctly set to the EXIF date helps keeping the photos sorted in the directory listings for multiple OS, so File->Export isn't a solution.

    File data is file data. Exif is photo data. A file is not a photo.  It's a container for a photo.
    When you export you're not exporting a file. You're exporting a Photo. The medium of export is a new file. That file is created at the time of export, so that's its creation date. The Photo within that file is dated by the Exif.
    There are apps that will modify the file date to match the Exif.
    The variation you're seeing is likely due to the changes in how the iPhoto library works over the past few versions. Drag and drop is handy, but is not a substitute for exporting, nor intended to be.

  • Robocopy not copying the folder creation date

    We migrate the data between 2  Windowsfile servers using robocopy and it works finew ith issues. Only issue is it doesnt copy the folder creatiopn date from source to destination server, it does copy the file creation date without any issues. Command
    we use is as below.
    robocopy.exe %1 %2 /COPYALL /MIR /ZB /R:10 /W:2 /TEE /DCOPY /LOG+:robocopy_%3.log
    This command is called using a batch file where we specify the source and destination using the below syntax.
    call Robocopy_Module.bat "C:\Backup" "C:\Restore"
    Kindly advise if this is normal behaviour , if not what is the correct command used to copy the Folder creation dates.

    I was using like this
    Go to CMD prompt,
    RUN as Administrator
    Type  
    robocopy "source path" "destination Path" / MIR
    It will copy including time stamps.
    or create seprate folder in a destination place and copy everything into that folder.
    It will work.

  • Get original file creation and modified date during upload - ONLY in explorerview ??

    Hi,
    SharePoint and me are having a difficult time again ;-)
    I have the customer requirement to retain the original file's creation date and modified date.
    Please do not start replying by just pasting links that you might find while searching for the keywords "retain creation date".
    In a nutshell I found out that the original dates are only available in SharePoint if the
    explorerview has been used. I always thought that the explorerview is a bad thing, but only here - the original creation date is stored in a property called "vti_ct". In the itemupdated eventreceiver you can get the
    value and work with it.
    Complete list of available properties
    http://sbrickey.com/Tech/Blog/Post/Secrets_Revealed_SP_Event_Receivers_firing_multiple_times
    Here I found the hint with the explorerview
    http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010programming.aspx?ID=57bfd5f5-941f-4a89-919d-cdf7b0b801be
    It is only available in the 2nd loop of the itemupdated event. 
    How the f*** can this happen??? The 2nd post states that when using the explorerview the file is being copied, while it is being re-created by using the SharePoint UI.
    Has anyone a different approach for using the SharePoint UI?
    I thought about different approaches for this issue. From my perspective it seems to be not solvable from the server-side. It seems only to be able to be set using a client application.
    Example 1: spbulkdocumentimport 
    http://spbulkdocumentimport.codeplex.com/wikipage?title=Features&referringTitle=Documentation
    Example 2: implement a custom webservice
    http://blog.orbitone.com/post/Preserve-created-and-modified-information-when-importing-a-document-in-SharePoint
    How do you deal with this customer requirement?
    Open for discussions
    Sven 

    Hi,
    Newbie to SharePoint, learn quite a lot from the links you provided.
    “I found out that the original dates are only available in SharePoint if the explorerview has been used”, this would make sense because the original creation time is generated
    by the file system in the local machine.
    However, when a file is uploaded to SharePoint library, it will be stored as binary data in the database, as well as the newly created time. It means that it will be a “new” file
    in the SharePoint site regardless of where it comes from.
    Per my knowledge, the only way I can suggest is that you will need to create a client desktop application for the file uploading, which will be a more general way not only for
    uploading a file, but also when we need to migrate files between different systems.
    Thanks

  • How can you determine a file creation date and know if it's been altered since the creation date

    I need to know how to determine a file creation date on an ipad.  If someone creates a document/note on an ipad how can you tell when it was created and if it has been altered since?

    Unless you are using a third party app that provides that functionality, in iOS the only thing youcan access is the last edit/save date and time, which is fairly evident in the user interface for documents and notes. Some apps that handle MS Office files may provide that, but ican't say first hand.

  • TS1627 I cannot open iTunes. This is the message I get:  "The file iTunes library .itl cannot be read because it was created by a newer version of iTunes. Would you like to download iTunes now?"  I did a download and it is up to date, but still won't open

    I cannot open iTunes. This is the message I get:  "The file iTunes library .itl cannot be read because it was created by a newer version of iTunes. Would you like to download iTunes now?"  I did a download and it is up to date, but still won't open.  HELP

    See Empty/corrupt iTunes library after upgrade/crash.
    tt2

  • How do I get the last changed date & time of a file in app server?

    Hi Experts,
    How do I get the last changed date & time of a file in app server?
    Thanks!
    - Anthony -

    Hi,
    that's what I use...
      CALL 'C_DIR_READ_FINISH'.             " just to be sure
      CALL 'C_DIR_READ_START' ID 'DIR' FIELD p_path.
      IF sy-subrc <> 0.
        EXIT. "Error
      ENDIF.
      DO.
        CLEAR l_srvfil.
        CALL 'C_DIR_READ_NEXT'
          ID 'TYPE'   FIELD l_srvfil-type
          ID 'NAME'   FIELD l_srvfil-file
          ID 'LEN'    FIELD l_srvfil-size
          ID 'OWNER'  FIELD l_srvfil-owner
          ID 'MTIME'  FIELD l_mtime
          ID 'MODE'   FIELD l_srvfil-attri.
    *    l_srvfil-dir = p_path .
        IF sy-subrc = 1.
          EXIT.
        ENDIF." sy-subrc <> 0.
        PERFORM p_to_date_time_tz
          USING    l_mtime
          CHANGING l_srvfil-mod_time
                   l_srvfil-mod_date.
        TRANSLATE l_srvfil-type TO UPPER CASE.               "#EC TRANSLANG
        PERFORM translate_attribute CHANGING l_srvfil-attri.
        CHECK:
          NOT l_srvfil-file = '.',
          l_srvfil-type = 'D' OR
          l_srvfil-type = 'F' .
        APPEND l_srvfil TO lt_srvfil.
      ENDDO.
      CHECK NOT lt_srvfil IS INITIAL.
      pt_srvfil = lt_srvfil.
    FORM p_to_date_time_tz  USING    p_ptime  TYPE p
                            CHANGING p_time   TYPE syuzeit
                                     p_date   TYPE sydatum.
      DATA:
        l_abaptstamp TYPE timestamp,
        l_time       TYPE int4,
        l_opcode     TYPE x VALUE 3,
        l_abstamp    TYPE abstamp.
      l_time = p_ptime.
      CALL 'RstrDateConv'
        ID 'OPCODE' FIELD l_opcode
        ID 'TIMESTAMP' FIELD l_time
        ID 'ABAPSTAMP' FIELD l_abstamp.
      l_abaptstamp = l_abstamp.
      CONVERT TIME STAMP l_abaptstamp TIME ZONE sy-zonlo INTO DATE p_date
          TIME p_time.
    ENDFORM.                    " p_to_date_time_tz
    Regards,
    Clemens

  • How do I get the file date...

    Hi,
    In Oracle form, after I upload the file to server from client machine using FileUploader90 or WebUtil, beyond the file name and directory, I would like to get the file date also. Does anyone know how?
    Thanks,
    Jess

    Hi Jessica,
    Please see Note:1043892.6 on Metalink. (How To Get Directory Information From Within Forms?)
    Monica

Maybe you are looking for