Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Change file creation date?

Reply
Thread Tools

Change file creation date?

 
 
die
Guest
Posts: n/a
 
      12-22-2004
# 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:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
jbl
Guest
Posts: n/a
 
      12-22-2004
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

 
Reply With Quote
 
 
 
 
Ken
Guest
Posts: n/a
 
      12-22-2004
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.



--------------------------------------------------------------------


 
Reply With Quote
 
Robert Sedlacek
Guest
Posts: n/a
 
      12-22-2004
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«

 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      12-22-2004
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?"
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      12-22-2004


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).

 
Reply With Quote
 
Chris Mattern
Guest
Posts: n/a
 
      12-22-2004
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?"
 
Reply With Quote
 
Peter Scott
Guest
Posts: n/a
 
      12-23-2004
In article <cqcnu0$rp6$(E-Mail Removed)>,
Brian McCauley <(E-Mail Removed)> 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/
 
Reply With Quote
 
jbl
Guest
Posts: n/a
 
      12-23-2004
On Wed, 22 Dec 2004 17:06:20 -0500, Chris Mattern
<(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change file creation timestamp in Perl? void.no.spam.com@gmail.com Perl Misc 0 06-17-2010 09:41 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
How to (batch) set EXIF date taken and IPTC creation date and creation time for photos with filenames YYMMDDHHMMSS#.jpg? guercheLE@gmail.com Digital Photography 1 10-04-2005 07:15 PM
Multiple File Deletions Based on Creation Dates crjunk ASP .Net 3 01-04-2005 03:01 PM
href link to code creation of file and open of that file Ryan ASP .Net 1 11-05-2004 08:37 PM



Advertisments