Page 1 of 1

How to change file date to creation date ?

Posted: Wed Oct 17, 2018 11:59 am
by ec91066
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.

Re: How to change file date to creation date ?

Posted: Wed Oct 17, 2018 12:07 pm
by WharfRat
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.

Re: How to change file date to creation date ?

Posted: Wed Oct 17, 2018 12:16 pm
by administrollaattori
One way is to pack file(s) and unpack the package.

Re: How to change file date to creation date ?

Posted: Wed Oct 17, 2018 12:24 pm
by ec91066
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

Re: How to change file date to creation date ?

Posted: Wed Oct 17, 2018 12:34 pm
by administrollaattori
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

Re: How to change file date to creation date ?

Posted: Wed Oct 17, 2018 1:06 pm
by gm10
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

Re: How to change file date to creation date ?

Posted: Thu Oct 18, 2018 8:00 am
by Hoser Rob
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.

Re: How to change file date to creation date ?

Posted: Thu Oct 18, 2018 8:15 am
by gm10
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.