Change file creation date?

D

die

# 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";
}
#---------------------------------------------------------------------------
 
J

jbl

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
 
K

Ken

jbl said:
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.



--------------------------------------------------------------------
 
C

Chris Mattern

jbl said:
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?"
 
B

Brian McCauley

Chris said:
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).
 
C

Chris Mattern

Brian said:
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?"
 
J

jbl

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top