Change file creation date?

Discussion in 'Perl Misc' started by die, Dec 22, 2004.

  1. die

    die Guest

    # This can be tested from the command line.$file2 should be an exact copy of
    $file1
    # with a current creation time.

    # NOTE: Other file statistics would also be changed.

    #---------------------------------------------------------------------------
    ----------
    $file1='C:/Perl/eg/temp/file1.html'; # put original files in temporary
    folder
    $file2='C:/Perl/eg/file1.html'; # copy new files to another
    directory

    unless(-e "$file2"){ #just a precaution

    use File::Copy; #method-use File::Copy;
    copy("$file1","$file2");

    use File::Compare; #use File::Compare;
    if(compare("$file1","$file2")==0){

    print"exact copy created\n";
    }
    }else{
    print"file already exists";
    }
    #---------------------------------------------------------------------------
    ----------

    # cd C:\perl\eg
    # perl newsgroup.pl



    "jbl" <j.b.l.0.2.@.hotmail.com> wrote in message
    news:...
    > I want to modify the file creation time to syncronize my local dates
    > with the dates on a server.
    >
    > I haven't found any way to do that yet
    > Using File::stat lets me read the file statistics for:
    >
    > meaning of the fields:
    >
    > 0 dev device number of filesystem
    > 1 ino inode number
    > 2 mode file mode (type and permissions)
    > 3 nlink number of (hard) links to the file
    > 4 uid numeric user ID of file's owner
    > 5 gid numeric group ID of file's owner
    > 6 rdev the device identifier (special files only)
    > 7 size total size of file, in bytes
    > 8 atime last access time since the epoch
    > 9 mtime last modify time since the epoch
    > 10 ctime inode change time (NOT creation time!) since the epoch
    > 11 blksize preferred block size for file system I/O
    > 12 blocks actual number of blocks allocated
    >
    > but I don't see creation date,
    > (ctime seems to be last change time)
    > and I only seem to be able to read these, not change them anyway.
    >
    > Thanls
    > jbl
    >
    die, Dec 22, 2004
    #1
    1. Advertising

  2. die

    jbl Guest

    I want to modify the file creation time to syncronize my local dates
    with the dates on a server.

    I haven't found any way to do that yet
    Using File::stat lets me read the file statistics for:

    meaning of the fields:

    0 dev device number of filesystem
    1 ino inode number
    2 mode file mode (type and permissions)
    3 nlink number of (hard) links to the file
    4 uid numeric user ID of file's owner
    5 gid numeric group ID of file's owner
    6 rdev the device identifier (special files only)
    7 size total size of file, in bytes
    8 atime last access time since the epoch
    9 mtime last modify time since the epoch
    10 ctime inode change time (NOT creation time!) since the epoch
    11 blksize preferred block size for file system I/O
    12 blocks actual number of blocks allocated

    but I don't see creation date,
    (ctime seems to be last change time)
    and I only seem to be able to read these, not change them anyway.

    Thanls
    jbl
    jbl, Dec 22, 2004
    #2
    1. Advertising

  3. die

    Ken Guest

    jbl wrote:
    > I want to modify the file creation time to syncronize my local dates
    > with the dates on a server.
    >
    > I haven't found any way to do that yet
    > Using File::stat lets me read the file statistics for:
    >
    > meaning of the fields:
    >
    > 0 dev device number of filesystem
    > 1 ino inode number
    > 2 mode file mode (type and permissions)
    > 3 nlink number of (hard) links to the file
    > 4 uid numeric user ID of file's owner
    > 5 gid numeric group ID of file's owner
    > 6 rdev the device identifier (special files only)
    > 7 size total size of file, in bytes
    > 8 atime last access time since the epoch
    > 9 mtime last modify time since the epoch
    > 10 ctime inode change time (NOT creation time!) since the epoch
    > 11 blksize preferred block size for file system I/O
    > 12 blocks actual number of blocks allocated
    >
    > but I don't see creation date,
    > (ctime seems to be last change time)
    > and I only seem to be able to read these, not change them anyway.
    >
    > Thanls
    > jbl
    >


    this is actually a FAQ:
    --------------------------------------------------------------------

    4.60: How can I always keep my hash sorted?

    You can look into using the DB_File module and tie() using the
    $DB_BTREE
    hash bindings as documented in "In Memory Databases" in DB_File. The
    Tie::IxHash module from CPAN might also be instructive.



    --------------------------------------------------------------------
    Ken, Dec 22, 2004
    #3
  4. Ken wrote:

    > this is actually a FAQ


    Hum, maybe that's not the answer to /all/ questions ;)

    scnr,
    Robert

    --
    http://www.dunkelheit.at/

    The mind is its own place, and in itself
    Can make a heaven of hell, a hell of heaven. -- Milton, »Paradise Lost«
    Robert Sedlacek, Dec 22, 2004
    #4
  5. jbl wrote:

    > I want to modify the file creation time to syncronize my local dates
    > with the dates on a server.


    You can't. There's no such thing as "file creation time", at least not
    on a Windows or UNIX computer. The filesystem does not track such a
    statistic.


    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Dec 22, 2004
    #5
  6. Chris Mattern wrote:

    > jbl wrote:
    >
    >>I want to modify the file creation time to syncronize my local dates
    >>with the dates on a server.

    >
    > You can't. There's no such thing as "file creation time", at least not
    > on a Windows or UNIX computer. The filesystem does not track such a
    > statistic.


    Er, NTFS5 does. (I think earlier NTFS did too).
    Brian McCauley, Dec 22, 2004
    #6
  7. Brian McCauley wrote:

    >
    >
    > Chris Mattern wrote:
    >
    >> jbl wrote:
    >>
    >>>I want to modify the file creation time to syncronize my local dates
    >>>with the dates on a server.

    >>
    >> You can't. There's no such thing as "file creation time", at least not
    >> on a Windows or UNIX computer. The filesystem does not track such a
    >> statistic.

    >
    > Er, NTFS5 does. (I think earlier NTFS did too).


    Ah, well, my Windows knowledge is is weaker than my UNIX knowledge.
    So noted.
    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Dec 22, 2004
    #7
  8. die

    Peter Scott Guest

    In article <cqcnu0$rp6$>,
    Brian McCauley <> writes:
    >Chris Mattern wrote:
    >> You can't. There's no such thing as "file creation time", at least not
    >> on a Windows or UNIX computer. The filesystem does not track such a
    >> statistic.

    >
    >Er, NTFS5 does. (I think earlier NTFS did too).


    VMS too. (Excuse me, OpenVMS.)

    --
    Peter Scott
    http://www.perldebugged.com/
    *** NEW *** http://www.perlmedic.com/
    Peter Scott, Dec 23, 2004
    #8
  9. die

    jbl Guest

    On Wed, 22 Dec 2004 17:06:20 -0500, Chris Mattern
    <> wrote:

    >Brian McCauley wrote:
    >
    >>
    >>
    >> Chris Mattern wrote:
    >>
    >>> jbl wrote:
    >>>
    >>>>I want to modify the file creation time to syncronize my local dates
    >>>>with the dates on a server.
    >>>
    >>> You can't. There's no such thing as "file creation time", at least not
    >>> on a Windows or UNIX computer. The filesystem does not track such a
    >>> statistic.

    >>
    >> Er, NTFS5 does. (I think earlier NTFS did too).

    >
    >Ah, well, my Windows knowledge is is weaker than my UNIX knowledge.
    >So noted.


    Thanks for the replies and help.
    I am using WindowsXP and I can see the file creation time.
    I was wanting to use the creation date as it is not volatile, like the
    last accessed time or modified time

    Thanks
    jbl
    jbl, Dec 23, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    515
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    719
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    405
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page