How to change file date to creation date ?

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
ec91066
Level 1
Level 1
Posts: 31
Joined: Wed Mar 26, 2014 7:14 pm

How to change file date to creation date ?

Post by ec91066 » Wed Oct 17, 2018 11:59 am

Hello,

I had to recover some fotos that have been erased from my archive by error :oops: . However, now these files present the date they were recovered, not the creation date when fotos were taken.

I want to change date to creation date in linux, not going to buy some software to do it on windows 8) .

Any suggestions will be appreciated.

Thanks.

User avatar
WharfRat
Level 20
Level 20
Posts: 11834
Joined: Thu Apr 07, 2011 8:15 pm

Re: How to change file date to creation date ?

Post by WharfRat » Wed Oct 17, 2018 12:07 pm

If you used the cp command the -a option preserves the original time, same as rsync with the -a option.

Whatever you used, you didn't specify, should have an option to preserve the date/time of the original file.
ImageImage

User avatar
administrollaattori
Level 15
Level 15
Posts: 5653
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Re: How to change file date to creation date ?

Post by administrollaattori » Wed Oct 17, 2018 12:16 pm

One way is to pack file(s) and unpack the package.

ec91066
Level 1
Level 1
Posts: 31
Joined: Wed Mar 26, 2014 7:14 pm

Re: How to change file date to creation date ?

Post by ec91066 » Wed Oct 17, 2018 12:24 pm

Hi WharfRat,

I have my archive mirrored in pCloud. I recovered my files from pCloud's trash folder but there's no option to set the original file date.

But I can see the creation date in the file's properties, so this information is not lost and it can be restored.

Thanks

User avatar
administrollaattori
Level 15
Level 15
Posts: 5653
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Re: How to change file date to creation date ?

Post by administrollaattori » Wed Oct 17, 2018 12:34 pm

ec91066 wrote:
Wed Oct 17, 2018 12:24 pm
But I can see the creation date in the file's properties, so this information is not lost and it can be restored.
Install exiftool

Code: Select all

apt install libimage-exiftool-perl
Check picture's metadata via Terminal like

Code: Select all

exiftool mökki3.jpg
mökki3.png
http://xahlee.info/img/metadata_in_image_files.html

gm10
Level 13
Level 13
Posts: 4609
Joined: Thu Jun 21, 2018 5:11 pm

Re: How to change file date to creation date ?

Post by gm10 » Wed Oct 17, 2018 1:06 pm

administrollaattori wrote:
Wed Oct 17, 2018 12:34 pm
ec91066 wrote:
Wed Oct 17, 2018 12:24 pm
But I can see the creation date in the file's properties, so this information is not lost and it can be restored.
Install exiftool

Code: Select all

apt install libimage-exiftool-perl
Check picture's metadata via Terminal like

Code: Select all

exiftool mökki3.jpg
mökki3.png

http://xahlee.info/img/metadata_in_image_files.html
Right tool, wrong screenshot (that's the file date). Using exiftool, for all .jpg files in a folder this will set all file dates to their creation date as per their exif tag, if any:

Code: Select all

for F in *.jpg;do exiftool -createdate -d "%Y-%m-%d %H:%M:%S" "$F"|awk -F': ' '{print $2}'|xargs -r touch $F -d;done

Hoser Rob
Level 12
Level 12
Posts: 4456
Joined: Sat Dec 15, 2012 8:57 am

Re: How to change file date to creation date ?

Post by Hoser Rob » Thu Oct 18, 2018 8:00 am

administrollaattori wrote:
Wed Oct 17, 2018 12:16 pm
One way is to pack file(s) and unpack the package.
New users are often surprised to discover that Linux/Unix file systems do not support file creation date. They support time of last modification, last access, and last modification of the file's inode and that's it.

So packing and unpacking is probably a good way to go about it.

gm10
Level 13
Level 13
Posts: 4609
Joined: Thu Jun 21, 2018 5:11 pm

Re: How to change file date to creation date ?

Post by gm10 » Thu Oct 18, 2018 8:15 am

Hoser Rob wrote:
Thu Oct 18, 2018 8:00 am
New users are often surprised to discover that Linux/Unix file systems do not support file creation date. They support time of last modification, last access, and last modification of the file's inode and that's it.
And veteran users are often surprised by some of the statements you make (SCNR :P). Of course Linux file systems support creation time. Here, for example, for ext4:
https://github.com/torvalds/linux/blob/ ... xt4.h#L750

But as OP already explained, it doesn't matter in this case because he's only got a cloud backup.

Post Reply

Return to “Other topics”